The following code causes a stack overflow but I don’t see why…
int _tmain(int argc, _TCHAR* argv[])
{
cout << "start";
char bmp[1024][768][3];
for (int p = 0; p < 9000; ++p)
{
for(int i = 0; i < 1024; ++i)
{
for(int j = 0; j < 768; ++j)
{
bmp[i][j][0] = 20;
}
}
}
cout << "Stop";
return 0;
}
Thanks
I would say it is likely because 1024 * 768 * 3 is
2,359,296which is probably too big for the local stack.You should instead allocate that on the heap.