This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: memory


Hi Josef,

>> Declaring char a[15000000] gives me segmentation fault with g++ (on RedHat 7.1). Any suggestions?

Your stack isn't big enough. Make your stack larger when you compile/run your program.

Alternatively, declare your char a[15000000] variable on the heap via "char* a = new char[15000000];", remember to manage the memory with a "delete[] a". Better yet, use a "vector<char> a(15000000, '\0');", which will manage the memory for you.

--Eljay


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]