function calls

This is a discussion on function calls within the C++ Programming forums, part of the General Programming Boards category; I have a question regarding function calls. If function with variable(s) calls another one, which calls another one ...etc, like ...

  1. #1
    Registered User
    Join Date
    Sep 2012
    Location
    germany
    Posts
    1

    Post function calls

    I have a question regarding function calls. If function with variable(s) calls another one, which calls another one ...etc, like a chain of function calls. Where and how are the memories(of variable for instance) stored/managed for each function calls? Are they stored in a single stack automatically? thank you very much in advance.

    example code:
    Code:
    int func1 (int x){
        int a = x;
        a += func2(x);
        return a;
    }
    
    int func2 (int x){
        int a = x;
        a += func3(x);
        return a;
    }
    
    int func3 (int x){
        int a = x;
        a += func4(x);
        return a;
    }
    and so forth...
    PS: I'm new to programming, just taking interest lately

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,915
    All local variables will be stored on the stack.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,505
    Call stack - Wikipedia, the free encyclopedia
    You're welcome to ask for clarification, if you can't understand any part of that page.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  4. #4
    Registered User
    Join Date
    Aug 2005
    Posts
    266
    Yep, your thinking is correct that it's a 'single' stack as well.
    Check out my programming / algorithm blog @ http://www.swageroo.com

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pointers and function calls inside a function
    By lexitron in forum C Programming
    Replies: 1
    Last Post: 12-03-2011, 05:43 PM
  2. Replies: 19
    Last Post: 09-08-2011, 08:56 AM
  3. arg...function calls
    By 2fastwrx in forum C++ Programming
    Replies: 8
    Last Post: 09-23-2004, 11:55 PM
  4. Function calls
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 07-18-2002, 05:01 PM
  5. Function calls
    By Zewu in forum C++ Programming
    Replies: 2
    Last Post: 05-02-2002, 05:44 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21