Re: Progam not running
"vj" <email@example.com> wrote in message
I am using C++Builder V5.0 to run my C programs. I am not an expert in
C. Normally, I run the C program with these steps: 'Compile', 'Make
Project', 'Build Project' and then 'Run'. Many a times, I have a stack
overflow error due to huge amount of data processing involved, and for
this, I go to Options--Linker and increase the MaxStackSize, which
sorts out the problem.
All of a sudden, I have started to get trouble with one of my
programs, and I know I have run this program successfully in the past.
The problem is : When I click on 'Make Project' after 'Compile Unit'
operation, I get the following error dialog box:
C++ Builder Development Environment has encountered a problem and
needs to close. We are sorry for the inconvenience. Please tell
Microsoft about this problem. (Send)(Don't Send) etc.
The other C programs, some of which in the same directory, are running
alright. This particular program has huge data involved. Within this
program, if I decrease the array dimensions, it works fine. I have
freed some memory also from my hard disk suspecting that this problem
may be due to insufficient memory, but that doesn't serve the purpose.
Any suggestions are most welcome.
If you are having to increase your stack for your programs to run, you
should probably use the freestore instead of stack memory.
That is, instead of having:
you should do:
MyArray = malloc( sizeof( int ) * 10000 );
free( MyArray );
when you are done with the memory.
(In C++ you would use new and delete).
Check for MyArray being null. I don't remember if you have to cast it in C
or not. Either C or C++ you have to cast from malloc, but I don't remember
which. Anyway, this will use the freestore which you have a lot more of.
The other reason you could need a lot of stack space is because of
recursion, not much you can do there except either make it non recursive or
just increase the stack size.