The C functions: function calls and returns showing the execution flow C program example

 

Compiler: Visual C++ Express Edition 2005

Compiled on Platform: Windows XP Pro SP2

Header file: Standard

Additional library: none/default

Additional project setting: Set project to be compiled as C

Project -> your_project_name Properties -> Configuration Properties -> C/C++ -> Advanced -> Compiled As: Compiled as C Code (/TC)

Other info:

To do: Showing the flow of C function call and return processes

To show: How the function call and return execution flow in C program

 

 

#include <stdio.h>

 

/* Function prototypes */

int a();

int b();

int c();

 

/* Function definitions */

int a(void)

{

printf("I'm in a(), calling b() and then c()...\n");

b();

c();

return 0;

}

 

int b(void)

{

printf("I'm in b()...\n");

return 0;

}

 

int c(void)

{

printf("I'm in c()...\n");

return 0;

}

 

int main(void)

{

printf("I'm in main()...\n");

a();

b();

c();

return 0;

}

 

Output example:

 

I'm in main()...

I'm in a(), calling b() and then c()...

I'm in b()...

I'm in c()...

I'm in b()...

I'm in c()...

Press any key to continue . . .

 

 

C and C++ Programming Resources | C & C++ Code Example Index