[Ilugc] C pgm - Recursive -segmentation fault
- From: praveen@xxxxxxxxxxx (Praveen)
- Date: Tue Sep 14 10:55:03 2004
Kannan_Ranganathan wrote:
void R()
{
static int i =0;
i++;
/* printf("%d\n",i);*/
R();
}
int main()
{
R();
}
in my Home ...the same program which was sent earlier.
This program is still running well above 12 hrs (running since last night
till I left for office this morning ) ... My machine is a P2 /64 MB ram.
I am sure it would have run more than 52K times ...Any clues what's
happening here ??? No segmentation fault nothing .
Don't exactly remember gcc version..
The earlier version of the program would have atleast run for some time, but
yours (without printf) would have seg faulted immediately.
The reason is the there is no console operation (printf). So, the code will
reach
the stack overflow condition in a second or two while the one with printf will
take some time to reach the same condition.
I am sure that you are missing out something if it runs for more than 12 hours
(Impossible) no matter your have 64MB or 64GB of memory. Cross check your
sources.
--
Praveen Kumar
Web :
http://myriad-zero.net
Blog :
http://blog.myriad-zero.net
Mobile : +91-98407-02060
Other related posts: