Test/C
문자에 대응하는 코드값 출력
kiostory
2017. 6. 5. 22:23
/* charcode.c-displays code number for a character */
#include <stdio.h>
int main(void)
{
char ch;
printf("Please enter a character.\n");
scanf("%c", &ch); /* user inputs character */
printf("The code for %c is %d.\n", ch, ch);
return 0;
}
실행결과 :
Please enter a character.
C
The code for C is 67.
Please enter a character.
c
The code for c is 99.
#include <stdio.h>
int main(void)
{
char ch;
printf("Please enter a character.\n");
scanf("%c", &ch); /* user inputs character */
printf("The code for %c is %d.\n", ch, ch);
return 0;
}
실행결과 :
Please enter a character.
C
The code for C is 67.
Please enter a character.
c
The code for c is 99.