Quote Originally Posted by jeron
Code:
 long int n,m,rj,l,x;
    bool used[n];                    //n is zero at this point
    ifstream in("koder.in");
    ofstream out("koder.out");
    in>>n;
    in>>m;
    for (int i=1;i<=n;i++)        //should be i < n
    {used[i]=false;}
The array 'used' is declared with 0 entries, n was declared in the previous line and initialized by the compiler I think to 0. However, even if it was declared with some other value, the FOR loops used to access the array are looping too far. For an array of size n, the largest index can be (n-1).
If you want a dynamically sized array, vectors are probably your best bet.
Actually, the compiler will not initialize any of the variables to any value. So, if uninitialized, they will contain garbage.

However, this is invalid, and shouldn't compile:
Code:
bool used[n];
You cannot create a dynamic array in this manner.

Viggy