Don't know what the problem is...

I wrote this in Code::Blocks and when I press F9 it shows me a black square (as it should), but it looks like it waits for me to write something.

#include<iostream>
using namespace std;

int main()
{
int a,b,c,d,e,f,g,h,v,i,F[63];
v=0;
for(i=0;i<=63;i++)
{
F[i]=0;
}

for(h=56;h<64;h++)
{
F[h]=1;
for(g=48;g<56;g++)
{
F[g]=1;
for(f=40;f<48;f++)
{
F[f]=1;
for(e=32;e<40;e++)
{
F[e]=1;
for(d=24;d<32;d++)
{
F[d]=1;
for(c=16;c<1;c++)
{
F[c]=1;
for(b=8;b<16;b++)
{
F[b]=1;
for(a=0;a<8;a++)
F[a]=1;
for(i=0;i<=63;i++)
if(F[i]<56)
if(F[i]!=F[i+8])
{
v=v+1;
cout<<"v="<<v;
}




}
}
}
}
}
}
}
}
Array int F[63]; has 63 elements. Valid subscripts range from 0 to 62 inclusive. But the code above attempts to assign a value to F[63].

63 is not a valid subscript, it is the 64th element, the element is outside the array. This will cause corruption of another area of memory with unpredictable results.

Suggested fix: increase the size of the array to int F[64];.

Topic archived. No new replies allowed.