C ctype isdigit() 函数
示例
检查字符是否为数字:
char c = '8';
if (isdigit(c)) {
printf("%c is a digit", c);
} else {
printf("%c is not a digit", c);
}
亲自试一试 »
定义和用法
isdigit() 函数如果字符是数字,则返回非零值(相当于布尔值 true)。
isdigit() 函数定义在 <ctype.h> 头文件中。
语法
int isdigit(int c);
参数值
| 参数 | 描述 |
|---|---|
| c | 必需。字符的 ASCII 值或实际字符 |
技术细节
| 返回值: | 如果字符是十进制数字,则返回非零值(相当于布尔值 true)。 否则返回 0(相当于布尔值 false)。 |
|---|

