[Ilugc] C pgm - Recursive -segmentation fault

  • From: gopalarathnam_v@xxxxxxxxx (Gopalarathnam V.)
  • Date: Mon Sep 13 17:22:10 2004

Probably you're out of memory (call stack)!
Any good recursive function should exit at some point in time say for
example:

void R()
{
        /* ... */
        if (i > 1000) return;
        /* ... */
}

HTH.

On Mon, 2004-09-13 at 16:59, Chakravarthi_Mohan wrote:

When I run this program, Recursive Function R(),

Called only 523714 times, after that segmentation fault occurs WHY?

void R()
{
    static int i =0;
    i++;
    printf("%d\n",i);

    R();
}

int main()
{
    R();
}

What is the problem here?


Regards,
Chakravarthi Mohan

************************************************************************** 
This email (including any attachments) is intended for the sole use of the
intended recipient/s and may contain material that is CONFIDENTIAL AND
PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or
distribution or forwarding of any or all of the contents in this message is
STRICTLY PROHIBITED. If you are not the intended recipient, please contact
the sender by email and delete all copies; your cooperation in this regard
is appreciated.
**************************************************************************
_______________________________________________
To unsubscribe, email ilugc-request@xxxxxxxxxxxxx with 
"unsubscribe <password> address"
in the subject or body of the message.  
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc
-- 
Gopalarathnam V.


Other related posts: