目录

isdigit

描述 (Description)

它检查字符是否为十进制数字。

声明 (Declaration)

以下是std :: isdigit的声明。

C++98

int isdigit ( int c );

C++11

int isdigit ( int c );

参数 (Parameters)

c - 要检查的字符,转换为int或EOF。

返回值 (Return Value)

它返回一个不等于零的值。

异常 (Exceptions)

No-throw guarantee - 此函数永远不会抛出异常。

例子 (Example)

在下面的示例中为std :: isdigit。

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main () {
   char str[]="2016ad";
   int year;
   if (isdigit(str[0])) {
      year = atoi (str);
      printf ("The year that followed %d was %d.\n",year,year+1);
   }
   return 0;
}

样本输出应该是这样的 -

 The year that followed 2016 was 2017.
↑回到顶部↑
WIKI教程 @2018