0

What is the size of an activation record for the function f()? How did you find out?

#include <stdio.h>
 
int K = 1024;
 
main(int argc, char *argv[])
{
     int n;
     int f() ;
     
     if (argc != 2) exit(-1);
     n = atoi(argv[1]);
     printf("Address of:\n K=%x \n main=%x \n argc=%x \n argv=%x \n");
     printf ("n=%x \n f=%x \n printf=%x \n", &K, &main, &argc, &argv, &n, &f);
     f(n) ;
}
 
int f(int n)
{ 
     int *m;
     static int s;
 
     m = (int*)malloc(K*sizeof(int));
     printf("f(%d) starts \n n=%x \n m=%x \n s=%x \n *m=%x \n", n, &n, &m, &s, m);
     
     if(n>0) f(n-1);
     
     printf("f(%d) returns\n", n);
     return;
}

Can any one explain that?

2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by Narue
0

>What is the size of an activation record for the function f()?
It depends on the compiler and there's really no reason for you to care in client code.

>How did you find out?
Experience and knowledge of the C standard.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.