메모리 할당과 할당 영역의 실체
This commit is contained in:
34
Variable/var-1.c
Normal file
34
Variable/var-1.c
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int globalVar = 10;
|
||||||
|
|
||||||
|
void func(int paraVar1, int paraVar2){
|
||||||
|
printf("매개변수 1 주소 : %p\n", (void*)¶Var1);
|
||||||
|
printf("매개변수 2 주소 : %p\n", (void*)¶Var2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void){
|
||||||
|
static int staticVar = 20;
|
||||||
|
int localVar = 30;
|
||||||
|
|
||||||
|
printf("main 함수 주소 : %p\n", (void*)main);
|
||||||
|
printf("func 함수 주소 : %p\n", (void*)func);
|
||||||
|
|
||||||
|
printf("전역변수 주소 : %p\n", (void*)&globalVar);
|
||||||
|
printf("정적변수 주소 : %p\n", (void*)&staticVar);
|
||||||
|
printf("지역변수 주소 : %p\n", (void*)&localVar);
|
||||||
|
|
||||||
|
func(localVar, staticVar);
|
||||||
|
|
||||||
|
int* heapVar;
|
||||||
|
heapVar = (int*)malloc(sizeof(int) * 4);
|
||||||
|
|
||||||
|
for(int i = 0; i < 4; i++){
|
||||||
|
printf("동적할당 주소 (%d) : %p\n", i, (void*)&heapVar[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(heapVar);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user