Hello there. I am new to this forum and it seems very good. I was programming in C with Windows and I need a 2d-array with 800x800 entries. It doesn't seem very big, but... when I run the program, it fails. Code: int main() { int M[800][800]; return 0; } In Linux all works well. Any tips? Regards, Ian Liu.
Your question does not lead to an appropriate response. Information is key. How does it fail? What messages do you get? Does the system just crash? Which Windows OS are you using? The size is not unduly large, but you may have an old underpowered (in terms of memory resources) system.
Oh yes... sorry, I was too "hungry" for a quick solution. Well, my PC is a: Pentium 4, 1.7 GHz 1GB RAM I use Windows XP with no SP versions installed (but I think it happened with SPed windows too). The error message is that pop-up window that appears when a program crashes and has to be closed. You have the option to report the error, or just finish it. It is something like this image: Sorry again for the bad post! Think this is usefull. Regards, Ian Liu.
I had no problem with your program with VC++ 6.0. It generated a stack overflow, however, with VC++ 2005. I checked the stack commit and stack reserve sizes in the project properties and found that both were set to 0. I set them to 1000 and fixed the problem. In 2005 you will find this at Project/(project name) Properties/Configuration Properties/Linker/System.
Oh yes, I forgot to say that I am not using VC++, I am using GCC, from DevCpp. I will try to install CygWin and see if the problem persist I don't like to use proprietary applications, but I wanted the program to work on windows. Any tips on GCC? Well, enough questions. Good night to you! Ian Liu.
Another reason you should provide all the information you can when asking a question. Let me recommend Smart Questions. With Dev-Cpp the program does indeed crash at 800 x 800. Dev-Cpp (gcc family, perhaps I should say) doesn't seem to offer an option for controlling the amount of stack allowed. Perhaps you should try allocating on the heap, as virtual memory in decent OSes tends to make the amount available unlimited (well, limited by disk size). You're certainly entitled to prefer non-proprietary tools, but sometimes you just get fewer amenities and capabilities. I never could convince ex-wife #2 that a high-heeled shoe wasn't really the best hammer.
Thank you very much DaWei. I think I've learned much more than I expected. I just don't agree with the hammer part Best wishes, Ian Liu.