문자 변수와 문자 상수 문자변수 문자상수 // 문자 상수 #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 컴퓨터 프로그래밍 기초 4
예제 #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. 컴퓨터 프로그래밍 기초 10
예제 #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 컴퓨터 프로그래밍 기초 11
문자열 역순 예제 #include <stdio. h> int main(void) { char src[] = "Seoul"; char dst[6]; int i; printf("원래 문자열=%sn", src); i = 0; while(src[i] != '