Write a program to check if the stack grows up or down.
1)Using c/c++ or Java, how to track stack grow up or shrink down
Try noting down the address of a local variable. Call another function with a local variable declared in it and check the address of that local variable and compare!.
1)Using c/c++ or Java, how to track stack grow up or shrink down
Try noting down the address of a local variable. Call another function with a local variable declared in it and check the address of that local variable and compare!.
void sub(int *a) {
int b;
if (&b > a) {
printf("Stack grows up.");
} else {
printf("Stack grows down.");
}
}
main () {
int a;
sub(&a);}
http://stackoverflow.com/questions/1677415/does-stack-grow-upward-or-downward