2020. 4. 19.

[c] 인프런 41. 아스키 코드 강의 정리


아스키 코드에 대해서 알아보겠다.
참고 :ASCII 코드? ANSI (미국표준협회) 에서 제시한 표준 코드 체계
7bit, 128개 코드 (0-127)
a : 97 (문자 a의 아스키코드 정수값)
A : 95
D : 48



#include<stdio.h>

int main(void)
{
printf("%c\n", 'a');
printf("%d\n", 'a');

printf("%c\n", 'b');
printf("%d\n", 'b');

printf("%c\n", 'A');
printf("%d\n", 'A');

printf("%c\n", '\0');
printf("%d\n", '\0');

printf("%c\n", '0');
printf("%d\n", '0');

printf("%c\n", '1');
printf("%d\n", '1');

return 0;
}


글자, 숫자, 공백이 표현하는 숫자가 다르다.

 0~127 사이의 아스키코드 정수값에 해당하는 문자 확인


#include<stdio.h>

int main(void)
{
for (int i = 0; i < 128; i++)
{
printf("아스키코드 정수 %d : %c\n", i, i);
}
return 0;
}


컴퓨터 소리내는 아스키코드도 있고 삭제, 엔터 등을 표현하는 수도 있다.


댓글 없음:

댓글 쓰기