I'm working on a rather big program. Everything works fine:) , until I added this simple code:
int counter_x = 0;
int* x = new int;
for (int a = 1; a < plain_len; a++) //plain_len: int
{
int b = a;
while ( b != 0 )
{
x[counter_x] = b;
cout << x[counter_x] << " ";
counter_x++;
b--;
}
cout << endl;
}
Run: (this time plain_len = 11)
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
6
Then: "Access violation reading location 0x00000021." comes up!
:(
What's wrong?
As I wrote before, this loop works a while, then the error occur.
Why?