Last active
August 4, 2017 08:20
-
-
Save sukeesh/94659d82b5224f5cebe790bc7a12a07a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int *go(int x){ | |
int y = 0; | |
if (x == 1){ | |
return &y; // Address of stack memory associated with local variable 'y' is returned | |
} | |
int *val = go(x - 1); | |
if ( val > &y ){ | |
cout << "Stack is growing towards higher address" << endl; | |
} | |
else{ | |
cout << "Stack is growing towards lower address" << endl; | |
} | |
return &y; | |
} | |
int main(){ | |
go(4); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment