Initial commit
This commit is contained in:
BIN
Final/FinalCode/stack/a.exe
Normal file
BIN
Final/FinalCode/stack/a.exe
Normal file
Binary file not shown.
24
Final/FinalCode/stack/stackmem.c
Normal file
24
Final/FinalCode/stack/stackmem.c
Normal file
@ -0,0 +1,24 @@
|
||||
#include <stdio.h>
|
||||
void print(int i) {
|
||||
printf("The location of i: %p\n", &i);
|
||||
int j;
|
||||
printf("The location of j: %p\n", &j);
|
||||
}
|
||||
|
||||
int main() {
|
||||
int i;
|
||||
i = 100;
|
||||
printf("The first variable on the stack: %p\n", &i);
|
||||
int *ptr;
|
||||
{
|
||||
int j;
|
||||
ptr = &j;
|
||||
j = 200;
|
||||
printf("The first location of j: %p\n", &j);
|
||||
}
|
||||
printf("The value of j out of its scope: %d\n", *ptr);
|
||||
int j;
|
||||
printf("The new location of j: %p\n", &j);
|
||||
|
||||
print(i);
|
||||
}
|
Reference in New Issue
Block a user