인수로 받은 문자가 숫자 문자인( '0'~'9')지를 판별합니다.
| 헤더 | ctype.h | |||||
| 형태 | int isdigit( int c) | |||||
| 인수 |
| |||||
| 반환 |
| |||||
예제
#include <stdio.h>
#include <ctype.h>
int main( void)
{
int ch1 = '1';
int ch2 = 'a';
int ch3 = 256; // 아스키값 이상
if ( isdigit( ch1))
printf( "%c(x%03x)는 숫자 문자입니다.\n", ch1, ch1);
else
printf( "%c(x%03x)는 숫자 문자가 아닙니다.\n", ch1, ch1);
if ( isdigit( ch2))
printf( "%c(x%03x)는 숫자 문자입니다.\n", ch2, ch2);
else
printf( "%c(x%03x)는 숫자 문자가 아닙니다.\n", ch2, ch2);
if ( isdigit( ch3))
printf( "%c(x%03x)는 숫자 문자입니다.\n", ch3, ch3);
else
printf( "%c(x%03x)는 숫자 문자가 아닙니다.\n", ch3, ch3);
return 0;
}반응형