SlideShare a Scribd company logo
최원빈 (bindon@korea.ac.kr)
고려대학교
2017. 05. 10.
C 프로그래밍 이론 및 실습
2
 이해해야 하는 포인트
 데이터 저장 방식(Endian)
 little-endian, big-endian의 차이
 각 영역의 특징, 순서, 저장 방식의 차이
 포인터와 배열의 차이
지난 과제 풀이
3
 String의 메모리가 어떻게 저장되는가?
지난 과제 풀이
[Code/Text]
Temp(static char *str4) 0x002F6B30 4444444444444444
Temp(static char *str8) 0x002F6B44 8888888888888888
Temp(char stack[6]) 0x002F6B58 STACK
printf에 사용된 매개변수 0x002F6B60 "%d %d"
printf에 사용된 매개변수 0x002F6B68 "%d, %dn"
Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA
printf("99~") 0x002F6C38 9999999999999999
Temp(char *str3) 0x002F6D38 3333333333333333
Temp(char bss[4]) 0x002F6D4C BSS
Temp(char str5[20]) 0x002F6E80 5555555555555555
Temp(char *str7) 0x002F6E94 7777777777777777
Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC
Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB
[Data]
char str1[20] 0x002F9000 1111111111111111
static char str2[20] 0x002F9014 2222222222222222
char *str3 0x002F9028 0x386D2F00
static char *str4 0x002F902B 0x306B2F00
char data[5] 0x002F9030 DATA
static char str6[20] 0x002F9038 6666666666666666
static char *str8 0x002F904C 0x446B2F00
[BSS]
char bss[4] 0x002F919C BSS
[Stack]
char * const str12 0x00F3F6F4 0xE46F2F00
char const *str11 0x00F3F700 0xAC742F00
const char *str10 0x00F3F70C 0x786B2F00
char *str7 0x00F3F718 0x946E2F00
char str5[20] 0x00F3F724 5555555555555555
char stack[6] 0x00F3F740 STACK
4
 String의 메모리가 어떻게 저장되는가?
지난 과제 풀이
[Code/Text]
Temp(static char *str4) 0x002F6B30 4444444444444444
Temp(static char *str8) 0x002F6B44 8888888888888888
Temp(char stack[6]) 0x002F6B58 STACK
printf에 사용된 매개변수 0x002F6B60 "%d %d"
printf에 사용된 매개변수 0x002F6B68 "%d, %dn"
Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA
printf("99~") 0x002F6C38 9999999999999999
Temp(char *str3) 0x002F6D38 3333333333333333
Temp(char bss[4]) 0x002F6D4C BSS
Temp(char str5[20]) 0x002F6E80 5555555555555555
Temp(char *str7) 0x002F6E94 7777777777777777
Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC
Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB
[Data]
char str1[20] 0x002F9000 1111111111111111
static char str2[20] 0x002F9014 2222222222222222
char *str3 0x002F9028 0x386D2F00
static char *str4 0x002F902B 0x306B2F00
char data[5] 0x002F9030 DATA
static char str6[20] 0x002F9038 6666666666666666
static char *str8 0x002F904C 0x446B2F00
[BSS]
char bss[4] 0x002F919C BSS
[Stack]
char * const str12 0x00F3F6F4 0xE46F2F00
char const *str11 0x00F3F700 0xAC742F00
const char *str10 0x00F3F70C 0x786B2F00
char *str7 0x00F3F718 0x946E2F00
char str5[20] 0x00F3F724 5555555555555555
char stack[6] 0x00F3F740 STACK
scope : global
type : char []
Data영역에 값이
직접 할당
5
 String의 메모리가 어떻게 저장되는가?
지난 과제 풀이
[Code/Text]
Temp(static char *str4) 0x002F6B30 4444444444444444
Temp(static char *str8) 0x002F6B44 8888888888888888
Temp(char stack[6]) 0x002F6B58 STACK
printf에 사용된 매개변수 0x002F6B60 "%d %d"
printf에 사용된 매개변수 0x002F6B68 "%d, %dn"
Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA
printf("99~") 0x002F6C38 9999999999999999
Temp(char *str3) 0x002F6D38 3333333333333333
Temp(char bss[4]) 0x002F6D4C BSS
Temp(char str5[20]) 0x002F6E80 5555555555555555
Temp(char *str7) 0x002F6E94 7777777777777777
Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC
Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB
[Data]
char str1[20] 0x002F9000 1111111111111111
static char str2[20] 0x002F9014 2222222222222222
char *str3 0x002F9028 0x386D2F00
static char *str4 0x002F902B 0x306B2F00
char data[5] 0x002F9030 DATA
static char str6[20] 0x002F9038 6666666666666666
static char *str8 0x002F904C 0x446B2F00
[BSS]
char bss[4] 0x002F919C BSS
[Stack]
char * const str12 0x00F3F6F4 0xE46F2F00
char const *str11 0x00F3F700 0xAC742F00
const char *str10 0x00F3F70C 0x786B2F00
char *str7 0x00F3F718 0x946E2F00
char str5[20] 0x00F3F724 5555555555555555
char stack[6] 0x00F3F740 STACK
scope : global
type : static char []
Data영역에 값이
직접 할당
6
 String의 메모리가 어떻게 저장되는가?
지난 과제 풀이
[Code/Text]
Temp(static char *str4) 0x002F6B30 4444444444444444
Temp(static char *str8) 0x002F6B44 8888888888888888
Temp(char stack[6]) 0x002F6B58 STACK
printf에 사용된 매개변수 0x002F6B60 "%d %d"
printf에 사용된 매개변수 0x002F6B68 "%d, %dn"
Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA
printf("99~") 0x002F6C38 9999999999999999
Temp(char *str3) 0x002F6D38 3333333333333333
Temp(char bss[4]) 0x002F6D4C BSS
Temp(char str5[20]) 0x002F6E80 5555555555555555
Temp(char *str7) 0x002F6E94 7777777777777777
Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC
Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB
[Data]
char str1[20] 0x002F9000 1111111111111111
static char str2[20] 0x002F9014 2222222222222222
char *str3 0x002F9028 0x386D2F00
static char *str4 0x002F902B 0x306B2F00
char data[5] 0x002F9030 DATA
static char str6[20] 0x002F9038 6666666666666666
static char *str8 0x002F904C 0x446B2F00
[BSS]
char bss[4] 0x002F919C BSS
[Stack]
char * const str12 0x00F3F6F4 0xE46F2F00
char const *str11 0x00F3F700 0xAC742F00
const char *str10 0x00F3F70C 0x786B2F00
char *str7 0x00F3F718 0x946E2F00
char str5[20] 0x00F3F724 5555555555555555
char stack[6] 0x00F3F740 STACK
scope : global
type : char *
Data영역에 주소 값
Code(Text)영역에 값
7
 String의 메모리가 어떻게 저장되는가?
지난 과제 풀이
[Code/Text]
Temp(static char *str4) 0x002F6B30 4444444444444444
Temp(static char *str8) 0x002F6B44 8888888888888888
Temp(char stack[6]) 0x002F6B58 STACK
printf에 사용된 매개변수 0x002F6B60 "%d %d"
printf에 사용된 매개변수 0x002F6B68 "%d, %dn"
Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA
printf("99~") 0x002F6C38 9999999999999999
Temp(char *str3) 0x002F6D38 3333333333333333
Temp(char bss[4]) 0x002F6D4C BSS
Temp(char str5[20]) 0x002F6E80 5555555555555555
Temp(char *str7) 0x002F6E94 7777777777777777
Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC
Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB
[Data]
char str1[20] 0x002F9000 1111111111111111
static char str2[20] 0x002F9014 2222222222222222
char *str3 0x002F9028 0x386D2F00
static char *str4 0x002F902B 0x306B2F00
char data[5] 0x002F9030 DATA
static char str6[20] 0x002F9038 6666666666666666
static char *str8 0x002F904C 0x446B2F00
[BSS]
char bss[4] 0x002F919C BSS
[Stack]
char * const str12 0x00F3F6F4 0xE46F2F00
char const *str11 0x00F3F700 0xAC742F00
const char *str10 0x00F3F70C 0x786B2F00
char *str7 0x00F3F718 0x946E2F00
char str5[20] 0x00F3F724 5555555555555555
char stack[6] 0x00F3F740 STACK
scope : global
type : static char *
Data영역에 주소 값
Code(Text)영역에 값
8
 String의 메모리가 어떻게 저장되는가?
지난 과제 풀이
[Code/Text]
Temp(static char *str4) 0x002F6B30 4444444444444444
Temp(static char *str8) 0x002F6B44 8888888888888888
Temp(char stack[6]) 0x002F6B58 STACK
printf에 사용된 매개변수 0x002F6B60 "%d %d"
printf에 사용된 매개변수 0x002F6B68 "%d, %dn"
Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA
printf("99~") 0x002F6C38 9999999999999999
Temp(char *str3) 0x002F6D38 3333333333333333
Temp(char bss[4]) 0x002F6D4C BSS
Temp(char str5[20]) 0x002F6E80 5555555555555555
Temp(char *str7) 0x002F6E94 7777777777777777
Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC
Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB
[Data]
char str1[20] 0x002F9000 1111111111111111
static char str2[20] 0x002F9014 2222222222222222
char *str3 0x002F9028 0x386D2F00
static char *str4 0x002F902B 0x306B2F00
char data[5] 0x002F9030 DATA
static char str6[20] 0x002F9038 6666666666666666
static char *str8 0x002F904C 0x446B2F00
[BSS]
char bss[4] 0x002F919C BSS
[Stack]
char * const str12 0x00F3F6F4 0xE46F2F00
char const *str11 0x00F3F700 0xAC742F00
const char *str10 0x00F3F70C 0x786B2F00
char *str7 0x00F3F718 0x946E2F00
char str5[20] 0x00F3F724 5555555555555555
char stack[6] 0x00F3F740 STACK
scope : global
type : char []
Data영역에 값이
직접 할당
9
 String의 메모리가 어떻게 저장되는가?
지난 과제 풀이
[Code/Text]
Temp(static char *str4) 0x002F6B30 4444444444444444
Temp(static char *str8) 0x002F6B44 8888888888888888
Temp(char stack[6]) 0x002F6B58 STACK
printf에 사용된 매개변수 0x002F6B60 "%d %d"
printf에 사용된 매개변수 0x002F6B68 "%d, %dn"
Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA
printf("99~") 0x002F6C38 9999999999999999
Temp(char *str3) 0x002F6D38 3333333333333333
Temp(char bss[4]) 0x002F6D4C BSS
Temp(char str5[20]) 0x002F6E80 5555555555555555
Temp(char *str7) 0x002F6E94 7777777777777777
Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC
Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB
[Data]
char str1[20] 0x002F9000 1111111111111111
static char str2[20] 0x002F9014 2222222222222222
char *str3 0x002F9028 0x386D2F00
static char *str4 0x002F902B 0x306B2F00
char data[5] 0x002F9030 DATA
static char str6[20] 0x002F9038 6666666666666666
static char *str8 0x002F904C 0x446B2F00
[BSS]
char bss[4] 0x002F919C BSS
[Stack]
char * const str12 0x00F3F6F4 0xE46F2F00
char const *str11 0x00F3F700 0xAC742F00
const char *str10 0x00F3F70C 0x786B2F00
char *str7 0x00F3F718 0x946E2F00
char str5[20] 0x00F3F724 5555555555555555
char stack[6] 0x00F3F740 STACK
scope : global
type : char []
BSS영역에 값이
직접 할당
10
 String의 메모리가 어떻게 저장되는가?
지난 과제 풀이
[Code/Text]
Temp(static char *str4) 0x002F6B30 4444444444444444
Temp(static char *str8) 0x002F6B44 8888888888888888
Temp(char stack[6]) 0x002F6B58 STACK
printf에 사용된 매개변수 0x002F6B60 "%d %d"
printf에 사용된 매개변수 0x002F6B68 "%d, %dn"
Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA
printf("99~") 0x002F6C38 9999999999999999
Temp(char *str3) 0x002F6D38 3333333333333333
Temp(char bss[4]) 0x002F6D4C BSS
Temp(char str5[20]) 0x002F6E80 5555555555555555
Temp(char *str7) 0x002F6E94 7777777777777777
Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC
Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB
[Data]
char str1[20] 0x002F9000 1111111111111111
static char str2[20] 0x002F9014 2222222222222222
char *str3 0x002F9028 0x386D2F00
static char *str4 0x002F902B 0x306B2F00
char data[5] 0x002F9030 DATA
static char str6[20] 0x002F9038 6666666666666666
static char *str8 0x002F904C 0x446B2F00
[BSS]
char bss[4] 0x002F919C BSS
[Stack]
char * const str12 0x00F3F6F4 0xE46F2F00
char const *str11 0x00F3F700 0xAC742F00
const char *str10 0x00F3F70C 0x786B2F00
char *str7 0x00F3F718 0x946E2F00
char str5[20] 0x00F3F724 5555555555555555
char stack[6] 0x00F3F740 STACK
scope : local
type : char []
Stack 영역에 값이
직접 할당
임시로 "STACK"을
Code영역에 저장
11
 String의 메모리가 어떻게 저장되는가?
지난 과제 풀이
[Code/Text]
Temp(static char *str4) 0x002F6B30 4444444444444444
Temp(static char *str8) 0x002F6B44 8888888888888888
Temp(char stack[6]) 0x002F6B58 STACK
printf에 사용된 매개변수 0x002F6B60 "%d %d"
printf에 사용된 매개변수 0x002F6B68 "%d, %dn"
Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA
printf("99~") 0x002F6C38 9999999999999999
Temp(char *str3) 0x002F6D38 3333333333333333
Temp(char bss[4]) 0x002F6D4C BSS
Temp(char str5[20]) 0x002F6E80 5555555555555555
Temp(char *str7) 0x002F6E94 7777777777777777
Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC
Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB
[Data]
char str1[20] 0x002F9000 1111111111111111
static char str2[20] 0x002F9014 2222222222222222
char *str3 0x002F9028 0x386D2F00
static char *str4 0x002F902B 0x306B2F00
char data[5] 0x002F9030 DATA
static char str6[20] 0x002F9038 6666666666666666
static char *str8 0x002F904C 0x446B2F00
[BSS]
char bss[4] 0x002F919C BSS
[Stack]
char * const str12 0x00F3F6F4 0xE46F2F00
char const *str11 0x00F3F700 0xAC742F00
const char *str10 0x00F3F70C 0x786B2F00
char *str7 0x00F3F718 0x946E2F00
char str5[20] 0x00F3F724 5555555555555555
char stack[6] 0x00F3F740 STACK
scope : temp
type : char []
Code(Text)영역에 값
12
 String의 메모리가 어떻게 저장되는가?
지난 과제 풀이
[Code/Text]
Temp(static char *str4) 0x002F6B30 4444444444444444
Temp(static char *str8) 0x002F6B44 8888888888888888
Temp(char stack[6]) 0x002F6B58 STACK
printf에 사용된 매개변수 0x002F6B60 "%d %d"
printf에 사용된 매개변수 0x002F6B68 "%d, %dn"
Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA
printf("99~") 0x002F6C38 9999999999999999
Temp(char *str3) 0x002F6D38 3333333333333333
Temp(char bss[4]) 0x002F6D4C BSS
Temp(char str5[20]) 0x002F6E80 5555555555555555
Temp(char *str7) 0x002F6E94 7777777777777777
Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC
Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB
[Data]
char str1[20] 0x002F9000 1111111111111111
static char str2[20] 0x002F9014 2222222222222222
char *str3 0x002F9028 0x386D2F00
static char *str4 0x002F902B 0x306B2F00
char data[5] 0x002F9030 DATA
static char str6[20] 0x002F9038 6666666666666666
static char *str8 0x002F904C 0x446B2F00
[BSS]
char bss[4] 0x002F919C BSS
[Stack]
char * const str12 0x00F3F6F4 0xE46F2F00
char const *str11 0x00F3F700 0xAC742F00
const char *str10 0x00F3F70C 0x786B2F00
char *str7 0x00F3F718 0x946E2F00
char str5[20] 0x00F3F724 5555555555555555
char stack[6] 0x00F3F740 STACK
scope : local
type : char []
Stack영역에 주소 값
Code(Text)영역에 값
13
 String의 메모리가 어떻게 저장되는가?
지난 과제 풀이
[Code/Text]
Temp(static char *str4) 0x002F6B30 4444444444444444
Temp(static char *str8) 0x002F6B44 8888888888888888
Temp(char stack[6]) 0x002F6B58 STACK
printf에 사용된 매개변수 0x002F6B60 "%d %d"
printf에 사용된 매개변수 0x002F6B68 "%d, %dn"
Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA
printf("99~") 0x002F6C38 9999999999999999
Temp(char *str3) 0x002F6D38 3333333333333333
Temp(char bss[4]) 0x002F6D4C BSS
Temp(char str5[20]) 0x002F6E80 5555555555555555
Temp(char *str7) 0x002F6E94 7777777777777777
Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC
Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB
[Data]
char str1[20] 0x002F9000 1111111111111111
static char str2[20] 0x002F9014 2222222222222222
char *str3 0x002F9028 0x386D2F00
static char *str4 0x002F902B 0x306B2F00
char data[5] 0x002F9030 DATA
static char str6[20] 0x002F9038 6666666666666666
static char *str8 0x002F904C 0x446B2F00
[BSS]
char bss[4] 0x002F919C BSS
[Stack]
char * const str12 0x00F3F6F4 0xE46F2F00
char const *str11 0x00F3F700 0xAC742F00
const char *str10 0x00F3F70C 0x786B2F00
char *str7 0x00F3F718 0x946E2F00
char str5[20] 0x00F3F724 5555555555555555
char stack[6] 0x00F3F740 STACK
scope : local
type : char []
Data영역에 값이
직접 할당
14
 String의 메모리가 어떻게 저장되는가?
지난 과제 풀이
[Code/Text]
Temp(static char *str4) 0x002F6B30 4444444444444444
Temp(static char *str8) 0x002F6B44 8888888888888888
Temp(char stack[6]) 0x002F6B58 STACK
printf에 사용된 매개변수 0x002F6B60 "%d %d"
printf에 사용된 매개변수 0x002F6B68 "%d, %dn"
Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA
printf("99~") 0x002F6C38 9999999999999999
Temp(char *str3) 0x002F6D38 3333333333333333
Temp(char bss[4]) 0x002F6D4C BSS
Temp(char str5[20]) 0x002F6E80 5555555555555555
Temp(char *str7) 0x002F6E94 7777777777777777
Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC
Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB
[Data]
char str1[20] 0x002F9000 1111111111111111
static char str2[20] 0x002F9014 2222222222222222
char *str3 0x002F9028 0x386D2F00
static char *str4 0x002F902B 0x306B2F00
char data[5] 0x002F9030 DATA
static char str6[20] 0x002F9038 6666666666666666
static char *str8 0x002F904C 0x446B2F00
[BSS]
char bss[4] 0x002F919C BSS
[Stack]
char * const str12 0x00F3F6F4 0xE46F2F00
char const *str11 0x00F3F700 0xAC742F00
const char *str10 0x00F3F70C 0x786B2F00
char *str7 0x00F3F718 0x946E2F00
char str5[20] 0x00F3F724 5555555555555555
char stack[6] 0x00F3F740 STACK
scope : local
type : char *
Stack영역에 주소 값
Code(Text)영역에 값
15
 String의 메모리가 어떻게 저장되는가?
지난 과제 풀이
[Code/Text]
Temp(static char *str4) 0x002F6B30 4444444444444444
Temp(static char *str8) 0x002F6B44 8888888888888888
Temp(char stack[6]) 0x002F6B58 STACK
printf에 사용된 매개변수 0x002F6B60 "%d %d"
printf에 사용된 매개변수 0x002F6B68 "%d, %dn"
Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA
printf("99~") 0x002F6C38 9999999999999999
Temp(char *str3) 0x002F6D38 3333333333333333
Temp(char bss[4]) 0x002F6D4C BSS
Temp(char str5[20]) 0x002F6E80 5555555555555555
Temp(char *str7) 0x002F6E94 7777777777777777
Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC
Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB
[Data]
char str1[20] 0x002F9000 1111111111111111
static char str2[20] 0x002F9014 2222222222222222
char *str3 0x002F9028 0x386D2F00
static char *str4 0x002F902B 0x306B2F00
char data[5] 0x002F9030 DATA
static char str6[20] 0x002F9038 6666666666666666
static char *str8 0x002F904C 0x446B2F00
[BSS]
char bss[4] 0x002F919C BSS
[Stack]
char * const str12 0x00F3F6F4 0xE46F2F00
char const *str11 0x00F3F700 0xAC742F00
const char *str10 0x00F3F70C 0x786B2F00
char *str7 0x00F3F718 0x946E2F00
char str5[20] 0x00F3F724 5555555555555555
char stack[6] 0x00F3F740 STACK
scope : local
type : char *
Stack영역에 주소 값
Code(Text)영역에 값
16
 String의 메모리가 어떻게 저장되는가?
지난 과제 풀이
[Code/Text]
Temp(static char *str4) 0x002F6B30 4444444444444444
Temp(static char *str8) 0x002F6B44 8888888888888888
Temp(char stack[6]) 0x002F6B58 STACK
printf에 사용된 매개변수 0x002F6B60 "%d %d"
printf에 사용된 매개변수 0x002F6B68 "%d, %dn"
Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA
printf("99~") 0x002F6C38 9999999999999999
Temp(char *str3) 0x002F6D38 3333333333333333
Temp(char bss[4]) 0x002F6D4C BSS
Temp(char str5[20]) 0x002F6E80 5555555555555555
Temp(char *str7) 0x002F6E94 7777777777777777
Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC
Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB
[Data]
char str1[20] 0x002F9000 1111111111111111
static char str2[20] 0x002F9014 2222222222222222
char *str3 0x002F9028 0x386D2F00
static char *str4 0x002F902B 0x306B2F00
char data[5] 0x002F9030 DATA
static char str6[20] 0x002F9038 6666666666666666
static char *str8 0x002F904C 0x446B2F00
[BSS]
char bss[4] 0x002F919C BSS
[Stack]
char * const str12 0x00F3F6F4 0xE46F2F00
char const *str11 0x00F3F700 0xAC742F00
const char *str10 0x00F3F70C 0x786B2F00
char *str7 0x00F3F718 0x946E2F00
char str5[20] 0x00F3F724 5555555555555555
char stack[6] 0x00F3F740 STACK
scope : local
type : ...
Stack영역에 주소 값
Code(Text)영역에 값
17
 String의 메모리가 어떻게 저장되는가?
지난 과제 풀이
[Code/Text]
Temp(static char *str4) 0x002F6B30 4444444444444444
Temp(static char *str8) 0x002F6B44 8888888888888888
Temp(char stack[6]) 0x002F6B58 STACK
printf에 사용된 매개변수 0x002F6B60 "%d %d"
printf에 사용된 매개변수 0x002F6B68 "%d, %dn"
Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA
printf("99~") 0x002F6C38 9999999999999999
Temp(char *str3) 0x002F6D38 3333333333333333
Temp(char bss[4]) 0x002F6D4C BSS
Temp(char str5[20]) 0x002F6E80 5555555555555555
Temp(char *str7) 0x002F6E94 7777777777777777
Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC
Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB
[Data]
char str1[20] 0x002F9000 1111111111111111
static char str2[20] 0x002F9014 2222222222222222
char *str3 0x002F9028 0x386D2F00
static char *str4 0x002F902B 0x306B2F00
char data[5] 0x002F9030 DATA
static char str6[20] 0x002F9038 6666666666666666
static char *str8 0x002F904C 0x446B2F00
[BSS]
char bss[4] 0x002F919C BSS
[Stack]
char * const str12 0x00F3F6F4 0xE46F2F00
char const *str11 0x00F3F700 0xAC742F00
const char *str10 0x00F3F70C 0x786B2F00
char *str7 0x00F3F718 0x946E2F00
char str5[20] 0x00F3F724 5555555555555555
char stack[6] 0x00F3F740 STACK
scope : local
type : const char *
Stack영역에 주소 값
Code(Text)영역에 값
18
 String의 메모리가 어떻게 저장되는가?
지난 과제 풀이
[Code/Text]
Temp(static char *str4) 0x002F6B30 4444444444444444
Temp(static char *str8) 0x002F6B44 8888888888888888
Temp(char stack[6]) 0x002F6B58 STACK
printf에 사용된 매개변수 0x002F6B60 "%d %d"
printf에 사용된 매개변수 0x002F6B68 "%d, %dn"
Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA
printf("99~") 0x002F6C38 9999999999999999
Temp(char *str3) 0x002F6D38 3333333333333333
Temp(char bss[4]) 0x002F6D4C BSS
Temp(char str5[20]) 0x002F6E80 5555555555555555
Temp(char *str7) 0x002F6E94 7777777777777777
Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC
Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB
[Data]
char str1[20] 0x002F9000 1111111111111111
static char str2[20] 0x002F9014 2222222222222222
char *str3 0x002F9028 0x386D2F00
static char *str4 0x002F902B 0x306B2F00
char data[5] 0x002F9030 DATA
static char str6[20] 0x002F9038 6666666666666666
static char *str8 0x002F904C 0x446B2F00
[BSS]
char bss[4] 0x002F919C BSS
[Stack]
char * const str12 0x00F3F6F4 0xE46F2F00
char const *str11 0x00F3F700 0xAC742F00
const char *str10 0x00F3F70C 0x786B2F00
char *str7 0x00F3F718 0x946E2F00
char str5[20] 0x00F3F724 5555555555555555
char stack[6] 0x00F3F740 STACK
scope : local
type : char const *
Stack영역에 주소 값
Code(Text)영역에 값
19
 String의 메모리가 어떻게 저장되는가?
지난 과제 풀이
[Code/Text]
Temp(static char *str4) 0x002F6B30 4444444444444444
Temp(static char *str8) 0x002F6B44 8888888888888888
Temp(char stack[6]) 0x002F6B58 STACK
printf에 사용된 매개변수 0x002F6B60 "%d %d"
printf에 사용된 매개변수 0x002F6B68 "%d, %dn"
Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA
printf("99~") 0x002F6C38 9999999999999999
Temp(char *str3) 0x002F6D38 3333333333333333
Temp(char bss[4]) 0x002F6D4C BSS
Temp(char str5[20]) 0x002F6E80 5555555555555555
Temp(char *str7) 0x002F6E94 7777777777777777
Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC
Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB
[Data]
char str1[20] 0x002F9000 1111111111111111
static char str2[20] 0x002F9014 2222222222222222
char *str3 0x002F9028 0x386D2F00
static char *str4 0x002F902B 0x306B2F00
char data[5] 0x002F9030 DATA
static char str6[20] 0x002F9038 6666666666666666
static char *str8 0x002F904C 0x446B2F00
[BSS]
char bss[4] 0x002F919C BSS
[Stack]
char * const str12 0x00F3F6F4 0xE46F2F00
char const *str11 0x00F3F700 0xAC742F00
const char *str10 0x00F3F70C 0x786B2F00
char *str7 0x00F3F718 0x946E2F00
char str5[20] 0x00F3F724 5555555555555555
char stack[6] 0x00F3F740 STACK
scope : local
type : char * const
Stack영역에 주소 값
Code(Text)영역에 값
20
 배열과 포인터의 차이?
포인터와 배열
21
 배열과 포인터의 차이?
포인터와 배열
O
O
변수
O
O
상수
22
포인터와 배열
23
포인터와 배열
 배열과 포인터의 차이?
 추가 실습
24
포인터와 배열
 배열의 범위(read)
25
포인터와 배열
 배열의 범위(read)
26
포인터와 배열
 배열의 범위(write)
27
포인터와 배열
 배열의 범위(write)
28
 배열의 변화
지난 과제 풀이
29
포인터와 배열
30
포인터와 배열
 Array 초기화 방법 Convention
 생각보다 dynamic allocation보다 static
allocation도 많이 사용함
 why? performance
 초기화 방법 비교하기!
1. int a[10] = { 0 };
2. int a[10] = { 0, };
3. int a[10];
memset ( a, 0, 10 );
31
Thank you

More Related Content

What's hot

Dsa 1
Dsa 1Dsa 1
How
HowHow
Program brian
Program brianProgram brian
Program brian
Brian Lara
 
โปรแกรมย่อยและฟังก์ชันมาตรฐาน
โปรแกรมย่อยและฟังก์ชันมาตรฐานโปรแกรมย่อยและฟังก์ชันมาตรฐาน
โปรแกรมย่อยและฟังก์ชันมาตรฐานknangsmiley
 
Javascrpt arale
Javascrpt araleJavascrpt arale
Javascrpt araleAlipay
 
Verilog coding of mux 8 x1
Verilog coding of mux  8 x1Verilog coding of mux  8 x1
Verilog coding of mux 8 x1
Rakesh kumar jha
 
Java осень 2012 лекция 6
Java осень 2012 лекция 6Java осень 2012 лекция 6
Java осень 2012 лекция 6Technopark
 
[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30
[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30
[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30
Chris Ohk
 
Verilog coding of demux 8 x1
Verilog coding of demux  8 x1Verilog coding of demux  8 x1
Verilog coding of demux 8 x1
Rakesh kumar jha
 

What's hot (13)

Dsa 1
Dsa 1Dsa 1
Dsa 1
 
Tugas pak putu
Tugas pak putuTugas pak putu
Tugas pak putu
 
All set1
All set1All set1
All set1
 
How
HowHow
How
 
Program brian
Program brianProgram brian
Program brian
 
โปรแกรมย่อยและฟังก์ชันมาตรฐาน
โปรแกรมย่อยและฟังก์ชันมาตรฐานโปรแกรมย่อยและฟังก์ชันมาตรฐาน
โปรแกรมย่อยและฟังก์ชันมาตรฐาน
 
Javascrpt arale
Javascrpt araleJavascrpt arale
Javascrpt arale
 
python-geohex
python-geohexpython-geohex
python-geohex
 
ikp213-06-template-c++
ikp213-06-template-c++ikp213-06-template-c++
ikp213-06-template-c++
 
Verilog coding of mux 8 x1
Verilog coding of mux  8 x1Verilog coding of mux  8 x1
Verilog coding of mux 8 x1
 
Java осень 2012 лекция 6
Java осень 2012 лекция 6Java осень 2012 лекция 6
Java осень 2012 лекция 6
 
[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30
[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30
[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30
 
Verilog coding of demux 8 x1
Verilog coding of demux  8 x1Verilog coding of demux  8 x1
Verilog coding of demux 8 x1
 

More from arundine

Cryptol 수업자료
Cryptol 수업자료Cryptol 수업자료
Cryptol 수업자료
arundine
 
[170605 7주차]C언어 A반
[170605 7주차]C언어 A반[170605 7주차]C언어 A반
[170605 7주차]C언어 A반
arundine
 
[170529 6주차]C언어 A반
[170529 6주차]C언어 A반[170529 6주차]C언어 A반
[170529 6주차]C언어 A반
arundine
 
[170517 5주차]C언어 A반
[170517 5주차]C언어 A반[170517 5주차]C언어 A반
[170517 5주차]C언어 A반
arundine
 
[170410 3주차]C언어 A반
[170410 3주차]C언어 A반[170410 3주차]C언어 A반
[170410 3주차]C언어 A반
arundine
 
[170403 2주차]C언어 A반
[170403 2주차]C언어 A반[170403 2주차]C언어 A반
[170403 2주차]C언어 A반
arundine
 
[170327 1주차]C언어 A반
[170327 1주차]C언어 A반[170327 1주차]C언어 A반
[170327 1주차]C언어 A반
arundine
 

More from arundine (7)

Cryptol 수업자료
Cryptol 수업자료Cryptol 수업자료
Cryptol 수업자료
 
[170605 7주차]C언어 A반
[170605 7주차]C언어 A반[170605 7주차]C언어 A반
[170605 7주차]C언어 A반
 
[170529 6주차]C언어 A반
[170529 6주차]C언어 A반[170529 6주차]C언어 A반
[170529 6주차]C언어 A반
 
[170517 5주차]C언어 A반
[170517 5주차]C언어 A반[170517 5주차]C언어 A반
[170517 5주차]C언어 A반
 
[170410 3주차]C언어 A반
[170410 3주차]C언어 A반[170410 3주차]C언어 A반
[170410 3주차]C언어 A반
 
[170403 2주차]C언어 A반
[170403 2주차]C언어 A반[170403 2주차]C언어 A반
[170403 2주차]C언어 A반
 
[170327 1주차]C언어 A반
[170327 1주차]C언어 A반[170327 1주차]C언어 A반
[170327 1주차]C언어 A반
 

[170510 4주차]C언어 A반

  • 1. 최원빈 (bindon@korea.ac.kr) 고려대학교 2017. 05. 10. C 프로그래밍 이론 및 실습
  • 2. 2  이해해야 하는 포인트  데이터 저장 방식(Endian)  little-endian, big-endian의 차이  각 영역의 특징, 순서, 저장 방식의 차이  포인터와 배열의 차이 지난 과제 풀이
  • 3. 3  String의 메모리가 어떻게 저장되는가? 지난 과제 풀이 [Code/Text] Temp(static char *str4) 0x002F6B30 4444444444444444 Temp(static char *str8) 0x002F6B44 8888888888888888 Temp(char stack[6]) 0x002F6B58 STACK printf에 사용된 매개변수 0x002F6B60 "%d %d" printf에 사용된 매개변수 0x002F6B68 "%d, %dn" Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA printf("99~") 0x002F6C38 9999999999999999 Temp(char *str3) 0x002F6D38 3333333333333333 Temp(char bss[4]) 0x002F6D4C BSS Temp(char str5[20]) 0x002F6E80 5555555555555555 Temp(char *str7) 0x002F6E94 7777777777777777 Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB [Data] char str1[20] 0x002F9000 1111111111111111 static char str2[20] 0x002F9014 2222222222222222 char *str3 0x002F9028 0x386D2F00 static char *str4 0x002F902B 0x306B2F00 char data[5] 0x002F9030 DATA static char str6[20] 0x002F9038 6666666666666666 static char *str8 0x002F904C 0x446B2F00 [BSS] char bss[4] 0x002F919C BSS [Stack] char * const str12 0x00F3F6F4 0xE46F2F00 char const *str11 0x00F3F700 0xAC742F00 const char *str10 0x00F3F70C 0x786B2F00 char *str7 0x00F3F718 0x946E2F00 char str5[20] 0x00F3F724 5555555555555555 char stack[6] 0x00F3F740 STACK
  • 4. 4  String의 메모리가 어떻게 저장되는가? 지난 과제 풀이 [Code/Text] Temp(static char *str4) 0x002F6B30 4444444444444444 Temp(static char *str8) 0x002F6B44 8888888888888888 Temp(char stack[6]) 0x002F6B58 STACK printf에 사용된 매개변수 0x002F6B60 "%d %d" printf에 사용된 매개변수 0x002F6B68 "%d, %dn" Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA printf("99~") 0x002F6C38 9999999999999999 Temp(char *str3) 0x002F6D38 3333333333333333 Temp(char bss[4]) 0x002F6D4C BSS Temp(char str5[20]) 0x002F6E80 5555555555555555 Temp(char *str7) 0x002F6E94 7777777777777777 Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB [Data] char str1[20] 0x002F9000 1111111111111111 static char str2[20] 0x002F9014 2222222222222222 char *str3 0x002F9028 0x386D2F00 static char *str4 0x002F902B 0x306B2F00 char data[5] 0x002F9030 DATA static char str6[20] 0x002F9038 6666666666666666 static char *str8 0x002F904C 0x446B2F00 [BSS] char bss[4] 0x002F919C BSS [Stack] char * const str12 0x00F3F6F4 0xE46F2F00 char const *str11 0x00F3F700 0xAC742F00 const char *str10 0x00F3F70C 0x786B2F00 char *str7 0x00F3F718 0x946E2F00 char str5[20] 0x00F3F724 5555555555555555 char stack[6] 0x00F3F740 STACK scope : global type : char [] Data영역에 값이 직접 할당
  • 5. 5  String의 메모리가 어떻게 저장되는가? 지난 과제 풀이 [Code/Text] Temp(static char *str4) 0x002F6B30 4444444444444444 Temp(static char *str8) 0x002F6B44 8888888888888888 Temp(char stack[6]) 0x002F6B58 STACK printf에 사용된 매개변수 0x002F6B60 "%d %d" printf에 사용된 매개변수 0x002F6B68 "%d, %dn" Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA printf("99~") 0x002F6C38 9999999999999999 Temp(char *str3) 0x002F6D38 3333333333333333 Temp(char bss[4]) 0x002F6D4C BSS Temp(char str5[20]) 0x002F6E80 5555555555555555 Temp(char *str7) 0x002F6E94 7777777777777777 Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB [Data] char str1[20] 0x002F9000 1111111111111111 static char str2[20] 0x002F9014 2222222222222222 char *str3 0x002F9028 0x386D2F00 static char *str4 0x002F902B 0x306B2F00 char data[5] 0x002F9030 DATA static char str6[20] 0x002F9038 6666666666666666 static char *str8 0x002F904C 0x446B2F00 [BSS] char bss[4] 0x002F919C BSS [Stack] char * const str12 0x00F3F6F4 0xE46F2F00 char const *str11 0x00F3F700 0xAC742F00 const char *str10 0x00F3F70C 0x786B2F00 char *str7 0x00F3F718 0x946E2F00 char str5[20] 0x00F3F724 5555555555555555 char stack[6] 0x00F3F740 STACK scope : global type : static char [] Data영역에 값이 직접 할당
  • 6. 6  String의 메모리가 어떻게 저장되는가? 지난 과제 풀이 [Code/Text] Temp(static char *str4) 0x002F6B30 4444444444444444 Temp(static char *str8) 0x002F6B44 8888888888888888 Temp(char stack[6]) 0x002F6B58 STACK printf에 사용된 매개변수 0x002F6B60 "%d %d" printf에 사용된 매개변수 0x002F6B68 "%d, %dn" Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA printf("99~") 0x002F6C38 9999999999999999 Temp(char *str3) 0x002F6D38 3333333333333333 Temp(char bss[4]) 0x002F6D4C BSS Temp(char str5[20]) 0x002F6E80 5555555555555555 Temp(char *str7) 0x002F6E94 7777777777777777 Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB [Data] char str1[20] 0x002F9000 1111111111111111 static char str2[20] 0x002F9014 2222222222222222 char *str3 0x002F9028 0x386D2F00 static char *str4 0x002F902B 0x306B2F00 char data[5] 0x002F9030 DATA static char str6[20] 0x002F9038 6666666666666666 static char *str8 0x002F904C 0x446B2F00 [BSS] char bss[4] 0x002F919C BSS [Stack] char * const str12 0x00F3F6F4 0xE46F2F00 char const *str11 0x00F3F700 0xAC742F00 const char *str10 0x00F3F70C 0x786B2F00 char *str7 0x00F3F718 0x946E2F00 char str5[20] 0x00F3F724 5555555555555555 char stack[6] 0x00F3F740 STACK scope : global type : char * Data영역에 주소 값 Code(Text)영역에 값
  • 7. 7  String의 메모리가 어떻게 저장되는가? 지난 과제 풀이 [Code/Text] Temp(static char *str4) 0x002F6B30 4444444444444444 Temp(static char *str8) 0x002F6B44 8888888888888888 Temp(char stack[6]) 0x002F6B58 STACK printf에 사용된 매개변수 0x002F6B60 "%d %d" printf에 사용된 매개변수 0x002F6B68 "%d, %dn" Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA printf("99~") 0x002F6C38 9999999999999999 Temp(char *str3) 0x002F6D38 3333333333333333 Temp(char bss[4]) 0x002F6D4C BSS Temp(char str5[20]) 0x002F6E80 5555555555555555 Temp(char *str7) 0x002F6E94 7777777777777777 Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB [Data] char str1[20] 0x002F9000 1111111111111111 static char str2[20] 0x002F9014 2222222222222222 char *str3 0x002F9028 0x386D2F00 static char *str4 0x002F902B 0x306B2F00 char data[5] 0x002F9030 DATA static char str6[20] 0x002F9038 6666666666666666 static char *str8 0x002F904C 0x446B2F00 [BSS] char bss[4] 0x002F919C BSS [Stack] char * const str12 0x00F3F6F4 0xE46F2F00 char const *str11 0x00F3F700 0xAC742F00 const char *str10 0x00F3F70C 0x786B2F00 char *str7 0x00F3F718 0x946E2F00 char str5[20] 0x00F3F724 5555555555555555 char stack[6] 0x00F3F740 STACK scope : global type : static char * Data영역에 주소 값 Code(Text)영역에 값
  • 8. 8  String의 메모리가 어떻게 저장되는가? 지난 과제 풀이 [Code/Text] Temp(static char *str4) 0x002F6B30 4444444444444444 Temp(static char *str8) 0x002F6B44 8888888888888888 Temp(char stack[6]) 0x002F6B58 STACK printf에 사용된 매개변수 0x002F6B60 "%d %d" printf에 사용된 매개변수 0x002F6B68 "%d, %dn" Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA printf("99~") 0x002F6C38 9999999999999999 Temp(char *str3) 0x002F6D38 3333333333333333 Temp(char bss[4]) 0x002F6D4C BSS Temp(char str5[20]) 0x002F6E80 5555555555555555 Temp(char *str7) 0x002F6E94 7777777777777777 Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB [Data] char str1[20] 0x002F9000 1111111111111111 static char str2[20] 0x002F9014 2222222222222222 char *str3 0x002F9028 0x386D2F00 static char *str4 0x002F902B 0x306B2F00 char data[5] 0x002F9030 DATA static char str6[20] 0x002F9038 6666666666666666 static char *str8 0x002F904C 0x446B2F00 [BSS] char bss[4] 0x002F919C BSS [Stack] char * const str12 0x00F3F6F4 0xE46F2F00 char const *str11 0x00F3F700 0xAC742F00 const char *str10 0x00F3F70C 0x786B2F00 char *str7 0x00F3F718 0x946E2F00 char str5[20] 0x00F3F724 5555555555555555 char stack[6] 0x00F3F740 STACK scope : global type : char [] Data영역에 값이 직접 할당
  • 9. 9  String의 메모리가 어떻게 저장되는가? 지난 과제 풀이 [Code/Text] Temp(static char *str4) 0x002F6B30 4444444444444444 Temp(static char *str8) 0x002F6B44 8888888888888888 Temp(char stack[6]) 0x002F6B58 STACK printf에 사용된 매개변수 0x002F6B60 "%d %d" printf에 사용된 매개변수 0x002F6B68 "%d, %dn" Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA printf("99~") 0x002F6C38 9999999999999999 Temp(char *str3) 0x002F6D38 3333333333333333 Temp(char bss[4]) 0x002F6D4C BSS Temp(char str5[20]) 0x002F6E80 5555555555555555 Temp(char *str7) 0x002F6E94 7777777777777777 Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB [Data] char str1[20] 0x002F9000 1111111111111111 static char str2[20] 0x002F9014 2222222222222222 char *str3 0x002F9028 0x386D2F00 static char *str4 0x002F902B 0x306B2F00 char data[5] 0x002F9030 DATA static char str6[20] 0x002F9038 6666666666666666 static char *str8 0x002F904C 0x446B2F00 [BSS] char bss[4] 0x002F919C BSS [Stack] char * const str12 0x00F3F6F4 0xE46F2F00 char const *str11 0x00F3F700 0xAC742F00 const char *str10 0x00F3F70C 0x786B2F00 char *str7 0x00F3F718 0x946E2F00 char str5[20] 0x00F3F724 5555555555555555 char stack[6] 0x00F3F740 STACK scope : global type : char [] BSS영역에 값이 직접 할당
  • 10. 10  String의 메모리가 어떻게 저장되는가? 지난 과제 풀이 [Code/Text] Temp(static char *str4) 0x002F6B30 4444444444444444 Temp(static char *str8) 0x002F6B44 8888888888888888 Temp(char stack[6]) 0x002F6B58 STACK printf에 사용된 매개변수 0x002F6B60 "%d %d" printf에 사용된 매개변수 0x002F6B68 "%d, %dn" Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA printf("99~") 0x002F6C38 9999999999999999 Temp(char *str3) 0x002F6D38 3333333333333333 Temp(char bss[4]) 0x002F6D4C BSS Temp(char str5[20]) 0x002F6E80 5555555555555555 Temp(char *str7) 0x002F6E94 7777777777777777 Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB [Data] char str1[20] 0x002F9000 1111111111111111 static char str2[20] 0x002F9014 2222222222222222 char *str3 0x002F9028 0x386D2F00 static char *str4 0x002F902B 0x306B2F00 char data[5] 0x002F9030 DATA static char str6[20] 0x002F9038 6666666666666666 static char *str8 0x002F904C 0x446B2F00 [BSS] char bss[4] 0x002F919C BSS [Stack] char * const str12 0x00F3F6F4 0xE46F2F00 char const *str11 0x00F3F700 0xAC742F00 const char *str10 0x00F3F70C 0x786B2F00 char *str7 0x00F3F718 0x946E2F00 char str5[20] 0x00F3F724 5555555555555555 char stack[6] 0x00F3F740 STACK scope : local type : char [] Stack 영역에 값이 직접 할당 임시로 "STACK"을 Code영역에 저장
  • 11. 11  String의 메모리가 어떻게 저장되는가? 지난 과제 풀이 [Code/Text] Temp(static char *str4) 0x002F6B30 4444444444444444 Temp(static char *str8) 0x002F6B44 8888888888888888 Temp(char stack[6]) 0x002F6B58 STACK printf에 사용된 매개변수 0x002F6B60 "%d %d" printf에 사용된 매개변수 0x002F6B68 "%d, %dn" Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA printf("99~") 0x002F6C38 9999999999999999 Temp(char *str3) 0x002F6D38 3333333333333333 Temp(char bss[4]) 0x002F6D4C BSS Temp(char str5[20]) 0x002F6E80 5555555555555555 Temp(char *str7) 0x002F6E94 7777777777777777 Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB [Data] char str1[20] 0x002F9000 1111111111111111 static char str2[20] 0x002F9014 2222222222222222 char *str3 0x002F9028 0x386D2F00 static char *str4 0x002F902B 0x306B2F00 char data[5] 0x002F9030 DATA static char str6[20] 0x002F9038 6666666666666666 static char *str8 0x002F904C 0x446B2F00 [BSS] char bss[4] 0x002F919C BSS [Stack] char * const str12 0x00F3F6F4 0xE46F2F00 char const *str11 0x00F3F700 0xAC742F00 const char *str10 0x00F3F70C 0x786B2F00 char *str7 0x00F3F718 0x946E2F00 char str5[20] 0x00F3F724 5555555555555555 char stack[6] 0x00F3F740 STACK scope : temp type : char [] Code(Text)영역에 값
  • 12. 12  String의 메모리가 어떻게 저장되는가? 지난 과제 풀이 [Code/Text] Temp(static char *str4) 0x002F6B30 4444444444444444 Temp(static char *str8) 0x002F6B44 8888888888888888 Temp(char stack[6]) 0x002F6B58 STACK printf에 사용된 매개변수 0x002F6B60 "%d %d" printf에 사용된 매개변수 0x002F6B68 "%d, %dn" Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA printf("99~") 0x002F6C38 9999999999999999 Temp(char *str3) 0x002F6D38 3333333333333333 Temp(char bss[4]) 0x002F6D4C BSS Temp(char str5[20]) 0x002F6E80 5555555555555555 Temp(char *str7) 0x002F6E94 7777777777777777 Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB [Data] char str1[20] 0x002F9000 1111111111111111 static char str2[20] 0x002F9014 2222222222222222 char *str3 0x002F9028 0x386D2F00 static char *str4 0x002F902B 0x306B2F00 char data[5] 0x002F9030 DATA static char str6[20] 0x002F9038 6666666666666666 static char *str8 0x002F904C 0x446B2F00 [BSS] char bss[4] 0x002F919C BSS [Stack] char * const str12 0x00F3F6F4 0xE46F2F00 char const *str11 0x00F3F700 0xAC742F00 const char *str10 0x00F3F70C 0x786B2F00 char *str7 0x00F3F718 0x946E2F00 char str5[20] 0x00F3F724 5555555555555555 char stack[6] 0x00F3F740 STACK scope : local type : char [] Stack영역에 주소 값 Code(Text)영역에 값
  • 13. 13  String의 메모리가 어떻게 저장되는가? 지난 과제 풀이 [Code/Text] Temp(static char *str4) 0x002F6B30 4444444444444444 Temp(static char *str8) 0x002F6B44 8888888888888888 Temp(char stack[6]) 0x002F6B58 STACK printf에 사용된 매개변수 0x002F6B60 "%d %d" printf에 사용된 매개변수 0x002F6B68 "%d, %dn" Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA printf("99~") 0x002F6C38 9999999999999999 Temp(char *str3) 0x002F6D38 3333333333333333 Temp(char bss[4]) 0x002F6D4C BSS Temp(char str5[20]) 0x002F6E80 5555555555555555 Temp(char *str7) 0x002F6E94 7777777777777777 Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB [Data] char str1[20] 0x002F9000 1111111111111111 static char str2[20] 0x002F9014 2222222222222222 char *str3 0x002F9028 0x386D2F00 static char *str4 0x002F902B 0x306B2F00 char data[5] 0x002F9030 DATA static char str6[20] 0x002F9038 6666666666666666 static char *str8 0x002F904C 0x446B2F00 [BSS] char bss[4] 0x002F919C BSS [Stack] char * const str12 0x00F3F6F4 0xE46F2F00 char const *str11 0x00F3F700 0xAC742F00 const char *str10 0x00F3F70C 0x786B2F00 char *str7 0x00F3F718 0x946E2F00 char str5[20] 0x00F3F724 5555555555555555 char stack[6] 0x00F3F740 STACK scope : local type : char [] Data영역에 값이 직접 할당
  • 14. 14  String의 메모리가 어떻게 저장되는가? 지난 과제 풀이 [Code/Text] Temp(static char *str4) 0x002F6B30 4444444444444444 Temp(static char *str8) 0x002F6B44 8888888888888888 Temp(char stack[6]) 0x002F6B58 STACK printf에 사용된 매개변수 0x002F6B60 "%d %d" printf에 사용된 매개변수 0x002F6B68 "%d, %dn" Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA printf("99~") 0x002F6C38 9999999999999999 Temp(char *str3) 0x002F6D38 3333333333333333 Temp(char bss[4]) 0x002F6D4C BSS Temp(char str5[20]) 0x002F6E80 5555555555555555 Temp(char *str7) 0x002F6E94 7777777777777777 Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB [Data] char str1[20] 0x002F9000 1111111111111111 static char str2[20] 0x002F9014 2222222222222222 char *str3 0x002F9028 0x386D2F00 static char *str4 0x002F902B 0x306B2F00 char data[5] 0x002F9030 DATA static char str6[20] 0x002F9038 6666666666666666 static char *str8 0x002F904C 0x446B2F00 [BSS] char bss[4] 0x002F919C BSS [Stack] char * const str12 0x00F3F6F4 0xE46F2F00 char const *str11 0x00F3F700 0xAC742F00 const char *str10 0x00F3F70C 0x786B2F00 char *str7 0x00F3F718 0x946E2F00 char str5[20] 0x00F3F724 5555555555555555 char stack[6] 0x00F3F740 STACK scope : local type : char * Stack영역에 주소 값 Code(Text)영역에 값
  • 15. 15  String의 메모리가 어떻게 저장되는가? 지난 과제 풀이 [Code/Text] Temp(static char *str4) 0x002F6B30 4444444444444444 Temp(static char *str8) 0x002F6B44 8888888888888888 Temp(char stack[6]) 0x002F6B58 STACK printf에 사용된 매개변수 0x002F6B60 "%d %d" printf에 사용된 매개변수 0x002F6B68 "%d, %dn" Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA printf("99~") 0x002F6C38 9999999999999999 Temp(char *str3) 0x002F6D38 3333333333333333 Temp(char bss[4]) 0x002F6D4C BSS Temp(char str5[20]) 0x002F6E80 5555555555555555 Temp(char *str7) 0x002F6E94 7777777777777777 Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB [Data] char str1[20] 0x002F9000 1111111111111111 static char str2[20] 0x002F9014 2222222222222222 char *str3 0x002F9028 0x386D2F00 static char *str4 0x002F902B 0x306B2F00 char data[5] 0x002F9030 DATA static char str6[20] 0x002F9038 6666666666666666 static char *str8 0x002F904C 0x446B2F00 [BSS] char bss[4] 0x002F919C BSS [Stack] char * const str12 0x00F3F6F4 0xE46F2F00 char const *str11 0x00F3F700 0xAC742F00 const char *str10 0x00F3F70C 0x786B2F00 char *str7 0x00F3F718 0x946E2F00 char str5[20] 0x00F3F724 5555555555555555 char stack[6] 0x00F3F740 STACK scope : local type : char * Stack영역에 주소 값 Code(Text)영역에 값
  • 16. 16  String의 메모리가 어떻게 저장되는가? 지난 과제 풀이 [Code/Text] Temp(static char *str4) 0x002F6B30 4444444444444444 Temp(static char *str8) 0x002F6B44 8888888888888888 Temp(char stack[6]) 0x002F6B58 STACK printf에 사용된 매개변수 0x002F6B60 "%d %d" printf에 사용된 매개변수 0x002F6B68 "%d, %dn" Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA printf("99~") 0x002F6C38 9999999999999999 Temp(char *str3) 0x002F6D38 3333333333333333 Temp(char bss[4]) 0x002F6D4C BSS Temp(char str5[20]) 0x002F6E80 5555555555555555 Temp(char *str7) 0x002F6E94 7777777777777777 Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB [Data] char str1[20] 0x002F9000 1111111111111111 static char str2[20] 0x002F9014 2222222222222222 char *str3 0x002F9028 0x386D2F00 static char *str4 0x002F902B 0x306B2F00 char data[5] 0x002F9030 DATA static char str6[20] 0x002F9038 6666666666666666 static char *str8 0x002F904C 0x446B2F00 [BSS] char bss[4] 0x002F919C BSS [Stack] char * const str12 0x00F3F6F4 0xE46F2F00 char const *str11 0x00F3F700 0xAC742F00 const char *str10 0x00F3F70C 0x786B2F00 char *str7 0x00F3F718 0x946E2F00 char str5[20] 0x00F3F724 5555555555555555 char stack[6] 0x00F3F740 STACK scope : local type : ... Stack영역에 주소 값 Code(Text)영역에 값
  • 17. 17  String의 메모리가 어떻게 저장되는가? 지난 과제 풀이 [Code/Text] Temp(static char *str4) 0x002F6B30 4444444444444444 Temp(static char *str8) 0x002F6B44 8888888888888888 Temp(char stack[6]) 0x002F6B58 STACK printf에 사용된 매개변수 0x002F6B60 "%d %d" printf에 사용된 매개변수 0x002F6B68 "%d, %dn" Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA printf("99~") 0x002F6C38 9999999999999999 Temp(char *str3) 0x002F6D38 3333333333333333 Temp(char bss[4]) 0x002F6D4C BSS Temp(char str5[20]) 0x002F6E80 5555555555555555 Temp(char *str7) 0x002F6E94 7777777777777777 Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB [Data] char str1[20] 0x002F9000 1111111111111111 static char str2[20] 0x002F9014 2222222222222222 char *str3 0x002F9028 0x386D2F00 static char *str4 0x002F902B 0x306B2F00 char data[5] 0x002F9030 DATA static char str6[20] 0x002F9038 6666666666666666 static char *str8 0x002F904C 0x446B2F00 [BSS] char bss[4] 0x002F919C BSS [Stack] char * const str12 0x00F3F6F4 0xE46F2F00 char const *str11 0x00F3F700 0xAC742F00 const char *str10 0x00F3F70C 0x786B2F00 char *str7 0x00F3F718 0x946E2F00 char str5[20] 0x00F3F724 5555555555555555 char stack[6] 0x00F3F740 STACK scope : local type : const char * Stack영역에 주소 값 Code(Text)영역에 값
  • 18. 18  String의 메모리가 어떻게 저장되는가? 지난 과제 풀이 [Code/Text] Temp(static char *str4) 0x002F6B30 4444444444444444 Temp(static char *str8) 0x002F6B44 8888888888888888 Temp(char stack[6]) 0x002F6B58 STACK printf에 사용된 매개변수 0x002F6B60 "%d %d" printf에 사용된 매개변수 0x002F6B68 "%d, %dn" Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA printf("99~") 0x002F6C38 9999999999999999 Temp(char *str3) 0x002F6D38 3333333333333333 Temp(char bss[4]) 0x002F6D4C BSS Temp(char str5[20]) 0x002F6E80 5555555555555555 Temp(char *str7) 0x002F6E94 7777777777777777 Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB [Data] char str1[20] 0x002F9000 1111111111111111 static char str2[20] 0x002F9014 2222222222222222 char *str3 0x002F9028 0x386D2F00 static char *str4 0x002F902B 0x306B2F00 char data[5] 0x002F9030 DATA static char str6[20] 0x002F9038 6666666666666666 static char *str8 0x002F904C 0x446B2F00 [BSS] char bss[4] 0x002F919C BSS [Stack] char * const str12 0x00F3F6F4 0xE46F2F00 char const *str11 0x00F3F700 0xAC742F00 const char *str10 0x00F3F70C 0x786B2F00 char *str7 0x00F3F718 0x946E2F00 char str5[20] 0x00F3F724 5555555555555555 char stack[6] 0x00F3F740 STACK scope : local type : char const * Stack영역에 주소 값 Code(Text)영역에 값
  • 19. 19  String의 메모리가 어떻게 저장되는가? 지난 과제 풀이 [Code/Text] Temp(static char *str4) 0x002F6B30 4444444444444444 Temp(static char *str8) 0x002F6B44 8888888888888888 Temp(char stack[6]) 0x002F6B58 STACK printf에 사용된 매개변수 0x002F6B60 "%d %d" printf에 사용된 매개변수 0x002F6B68 "%d, %dn" Temp(const char *str10) 0x002F6B78 AAAAAAAAAAAAAAAA printf("99~") 0x002F6C38 9999999999999999 Temp(char *str3) 0x002F6D38 3333333333333333 Temp(char bss[4]) 0x002F6D4C BSS Temp(char str5[20]) 0x002F6E80 5555555555555555 Temp(char *str7) 0x002F6E94 7777777777777777 Temp(char * const str12) 0x002F6FE4 CCCCCCCCCCCCCCCC Temp(char const *str11) 0x002F74AC BBBBBBBBBBBBBBBB [Data] char str1[20] 0x002F9000 1111111111111111 static char str2[20] 0x002F9014 2222222222222222 char *str3 0x002F9028 0x386D2F00 static char *str4 0x002F902B 0x306B2F00 char data[5] 0x002F9030 DATA static char str6[20] 0x002F9038 6666666666666666 static char *str8 0x002F904C 0x446B2F00 [BSS] char bss[4] 0x002F919C BSS [Stack] char * const str12 0x00F3F6F4 0xE46F2F00 char const *str11 0x00F3F700 0xAC742F00 const char *str10 0x00F3F70C 0x786B2F00 char *str7 0x00F3F718 0x946E2F00 char str5[20] 0x00F3F724 5555555555555555 char stack[6] 0x00F3F740 STACK scope : local type : char * const Stack영역에 주소 값 Code(Text)영역에 값
  • 20. 20  배열과 포인터의 차이? 포인터와 배열
  • 21. 21  배열과 포인터의 차이? 포인터와 배열 O O 변수 O O 상수
  • 23. 23 포인터와 배열  배열과 포인터의 차이?  추가 실습
  • 30. 30 포인터와 배열  Array 초기화 방법 Convention  생각보다 dynamic allocation보다 static allocation도 많이 사용함  why? performance  초기화 방법 비교하기! 1. int a[10] = { 0 }; 2. int a[10] = { 0, }; 3. int a[10]; memset ( a, 0, 10 );