Thread: Program error

  1. #1
    Registered User
    Join Date
    Mar 2012
    Posts
    20

    Program error

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    void f(void);
    void g(void);
    
     int main(void) {
       f();
    
       return 0;
     }
    
     void f(void) {
    
       g();
    
     }
    
     void g(void) {
       f();
    
     }
    I have that program and the objective is to identify the error so I started with the following statement:
    function f calls function g and this calls f and so one... So the stack at a point will just "blow up" and give segmentation fault. My point is: am I right about my point of view or is different ?

  2. #2
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    No you are right, g() and f() call each other infinitely, the limit is the space of the stack.

  3. #3
    Registered User
    Join Date
    Mar 2012
    Posts
    6
    you're right about "stack overflow", but some compilers throws this func

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 15
    Last Post: 11-28-2011, 11:48 AM
  2. Replies: 13
    Last Post: 11-03-2010, 12:45 PM
  3. C Program... Program or Compiler error?
    By Zemira in forum C Programming
    Replies: 13
    Last Post: 12-02-2009, 08:59 PM
  4. Replies: 18
    Last Post: 11-13-2006, 01:11 PM
  5. i'm trying to fix an error with my error messaging on my program
    By RancidWannaRiot in forum C++ Programming
    Replies: 10
    Last Post: 09-30-2003, 01:02 PM