-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPointer.c
More file actions
58 lines (45 loc) · 1 KB
/
Pointer.c
File metadata and controls
58 lines (45 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <stdio.h>
int main() {
int num = 5; // int - 정수
int* ptr; // int* - int 자료형을 가진 공간의 주소
int** dptr;
int*** tptr;
ptr = # // &(앰퍼샌드)
dptr = &ptr;
tptr = &dptr;
printf("num의 주소: %p\n", &num);
printf("ptr의 값: %p\n", ptr);
printf("\nnum의 값: %d\n", num);
printf("ptr을 이용한 num의 값: %d\n", *ptr);
printf("\nptr의 주소: %p\n", &ptr);
printf("dptr의 주소: %p\n", dptr);
printf("\ndptr의 주소: %p\n", &dptr);
printf("tptr의 주소: %p\n", tptr);
return 0;
}
// Q1) 정수형 변수를 선언하고 포인터 변수에 해당 변수의 주소 저장후, 정수형 변수의 값을 입력받기
// 입력 20 출력 20
/*
int main() {
int a;
int* ptr;
ptr = &a;
printf("입력 ");
scanf("%d", ptr);
printf("출력 %d\n", a);
return 0;
}*/
/*
void Func() {
int n1 = 3;
static int n2 = 3;
printf("n1: %d, n2: %d\n", n1, n2);
n1++;
n2++;
}
int main() {
Func();
Func();
//printf("n2의 값: %d\n", n2);
return 0;
}*/