I’m using VS 2010.
When I run this program in the Debug mode it throws Stack overflow exception and shows a breakline in the file chkstk.asm at line 99.
But when I run it in the Release mode it’s OK.
Also if I decrease the size of one of the arrays to 10000 it works well in Debug. What is the reason?
#include <iostream>
using namespace std;
int main()
{
char w[1000001], temp[1000001];
cout<<"Why?"<<endl;
return 0;
}
Because the stack is pretty small, approx 1MB on most systems, you’re overflowing it with your large buffers. To fix that, just allocate on the heap like this: