C- Programming/변수와 자료형

문자 상수 사용하기

Iraphael 2013. 9. 10. 13:56


#include <stdio.h>

int main()
{
     printf("%c\n", 'a');
     printf("%c\n", 97);
     printf("%c\n", '\141');
 
     printf("삐음 : %c\n", '\a');
     printf("단일 인용부호 : %c\n", '\'');
     printf("abcdef'b'b'b'b");
     printf("%s \n", "ghijk");

     return 0;
}

 

실행결과

a

a

a

a

삐음 :

단일 인용부호 : '

abghijk

 

참고로 아스키 문자 전체를 보고 싶다면 이 소스코드를 디버깅한후 실행 시켜보면 알수 있다.

 

#include <stdio.h.

int main()

{

int i;

for(i=65; i<127; i++)

{

printf("%c, %d \n", i, i);

}

return 0;

}

 

실행결과는 따로 올리지는 않겠습니다.