C언어/C언어 이론
[C언어] 문자가 숫자인지 아닌지 판별하기 - isdigit 함수
renne
2022. 8. 10. 23:27
헤더: <ctype.h>
| isdigit | int isdigit (int arg); | 인자가 숫자가 아니면 0(false) 반환 |
| 인자가 숫자이면 1 이상(true) 반환 |
#include <stdio.h>
#include <ctype.h>
int main(){
char test[11] = "hello12345";
for (int i = 0; i < 10; i++){
printf("%d", isdigit(test[i])); //0000011111 출력
}
return 0;
}