Thread: transforming this loop into a recursive function question

  1. #16
    Registered User
    Join Date
    Jul 2008
    Posts
    11
    Hi another recursive question: every time the function call itself, a new instance is copied on the stack?, or am i wrong? ( im trying to learn C, please dont shoot me ).

  2. #17
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    a new instance is copied
    a new instance of what? function is not an object
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #18
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by pic-o-matic View Post
    Hi another recursive question: every time the function call itself, a new instance is copied on the stack?, or am i wrong? ( im trying to learn C, please dont shoot me ).
    The parameters and return address is indeed pushed onto the stack, and when the recursive function call returns, they are popped back off the stack.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  3. recursive function
    By technosavvy in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 05:42 AM
  4. Question on function syntax and calling function
    By cbrman in forum C Programming
    Replies: 10
    Last Post: 10-05-2003, 05:32 PM
  5. what does this warningmean???
    By kreyes in forum C Programming
    Replies: 5
    Last Post: 03-04-2002, 07:53 AM