The program is trying to allocate too much stack space:
char *outputGwb = char[size]; // array is created "on the stack"
Use malloc
(or new
in C++) to allocate memory from the heap. Make sure to free
(or delete
in C++) the memory later; just don't mix the allocation/deallocation strategies.
char* outputGwb = new char[size]; // C++: note use of the "new" keyword
char* outputGwb = malloc(size); // C: note no cast needed in a C compiler
This issue is thus about the maximum size of a particular resource and is not related to the maximum number an integer value can represent.
See What and where are the stack and heap? for an explanation between the two memory allocation areas. In addition, while I wouldn't necessarily recommend it, here is a thread that discusses how to change the stack size in Visual C++.