C 库函数 - isdigit()
C 语言教程
· 2019-02-22 20:12:52
描述
C 库函数 void isdigit(int c) 检查所传的字符是否是十进制数字字符。
十进制数字是:0 1 2 3 4 5 6 7 8 9
声明
下面是 isdigit() 函数的声明。
int isdigit(int c);
参数
- c -- 这是要检查的字符。
返回值
如果 c 是一个数字,则该函数返回非零值,否则返回 0。
实例
下面的实例演示了 isdigit() 函数的用法。
#include <stdio.h>
#include <ctype.h>
int main()
{
int var1 = 'h';
int var2 = '2';
if( isdigit(var1) )
{
printf("var1 = |%c| 是一个数字\n", var1 );
}
else
{
printf("var1 = |%c| 不是一个数字\n", var1 );
}
if( isdigit(var2) )
{
printf("var2 = |%c| 是一个数字\n", var2 );
}
else
{
printf("var2 = |%c| 不是一个数字\n", var2 );
}
return(0);
}
让我们编译并运行上面的程序,这将产生以下结果:
var1 = |h| 不是一个数字 var2 = |2| 是一个数字
点击查看所有 C 语言教程 文章: https://codercto.com/courses/l/17.html
Numerical Methods and Methods of Approximation in Science and En
Karan Surana / CRC Press / 2018-10-31
ABOUT THIS BOOK Numerical Methods and Methods of Approximation in Science and Engineering prepares students and other readers for advanced studies involving applied numerical and computational anal......一起来看看 《Numerical Methods and Methods of Approximation in Science and En》 这本书的介绍吧!