/* * stack.c * * Computer Science 50, Fall 2011 * section4 * * Working with variables created in the stack. */ #include // functions prototypes int* f(); int* g(); int main(void) { // creates a pointer to a variable created in f() int* x = f(); printf("x has the value: %d\n", *x); // creates a pointer to a variable created in g() int* y = g(); printf("x (still) has the value %d\n", *x); printf("y has the value %d\n", *y); } int* f() { // creates a local variables and returns its address int a = 5; return &a; } int* g() { // creates a local variables and returns its address int b = 10; return &b; }