#include <stdio.h>
int doHello(){
doHello();
}
int main(){
doHello();
printf("\nLeaving Main");
return 0;
}
When you run the program quits without printing the message "Leaving Main" on the screen. This is a case of Stack Overflow and because of which program is terminating but I don't see any error messages on the command window. (Ran on Windows/Cygwin/)
Q1. I have not declared any local variables in the doHello function but still stack is getting used. Is this is because of
- return values
- information stored about the function calls?
Clarification
Q2. How to debug such cases in your program? I am not asking to debug an infinite loop which I mentioned above.
for example:
#define SIZE 512*1024
void doOVerflow(){
char str[SIZE];
doHello();
}
void doHello(){
char strHello[256]; // stack gets filled up at this point
doNothing(); // program terminates and function doNothing does not get called
}
EDIT:
Q3. What information is stored in run time stack?