Computational Intelligence

C언어 문자의 표현

초인로크 2014. 5. 9. 17:14
반응형
프로그래밍을 하다보면 변수형 때문에 고민을 하게 되는데,

Colored By Color Scripter
1
2
3
4
5
6
7
8
9
10
11
#include <stdio.h>
int main(int argc, const char * argv[])
{
    // insert code here...
    int number = 48;
    char number_1 = '0';
    
    printf("%c, %c\n",number,number_1);
    printf("%d, %d\n",number,number_1);
    return 0;
}


위와 같이 해보면 아래와 같이 출력된다.



요점은  모든 문자는 숫자로 표현된다.


단지 서식문자를 이용하면, 컴퓨터가 그 숫자에 해당하는 문자를 아스키 코드 표에서 찾아 출력 할 뿐이다.


반응형