C Express 12 2007 All rights reserved ress Slides: 44 Download presentation 쉽게 풀어쓴 C언어 Express 제 12장 문자와 문자열 © 2007 생능출판사 All rights reserved ress p C Ex 문자 변수와 문자 상수 문자변수 // 문자 상수 #include <stdio. h> int main(void) { char code 1 = 'A'; char code 2 = 65; printf("code 1=%c, code 1=%dn", code 1); printf("code 2=%c, code 2=%dn", code 2); return 0; } code 1=A, code 1=65 code 2=A, code 2=65 © 2007 생능출판사 All rights reserved 문자상수 예제 #1 #include <stdio. h> int main(void) { char str 1[6] = "Seoul" char str 2[3] = { 'i', 's' }; char str 3[] = "the capital city of Korea. " printf("%s %s %sn", str 1, str 2, str 3); } Seoul is the capital city of Korea. © 2007 생능출판사 All rights reserved 예제 #2 #include <stdio. h> int main(void) { char str[] = "komputer"; int i; for(i=0; i<8; i++) printf("%c ", str[i]); str[0] = 'c'; printf("n"); for(i=0; i<8; i++) printf("%c ", str[i]); return 0 komputer computer © 2007 생능출판사 All rights reserved 문자열 역순 예제 #include <stdio. h> int main(void) { char src[] = "Seoul"; char dst[6]; int i; printf("원래 문자열=%sn", src); i = 0; while(src[i] != '