isdigit - C ctype.h

C examples for ctype.h:isdigit

Type

function

From

<cctype> 
<ctype.h>

Description

Check if character is decimal digit. Decimal digits are any of: 0 1 2 3 4 5 6 7 8 9.

Prototype

int isdigit ( int c );

Parameters

Parameter Description
c Character to be checked, casted to an int, or EOF.

Return Value

A non zero value (i.e., true) if indeed c is a decimal digit. Zero (i.e., false) otherwise.

Demo Code


#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main ()/*from   ww  w  .jav a 2s . c om*/
{
  char str[]="this is a test 1776 test";
  int year;
  if (isdigit(str[0]))
  {
    year = atoi (str);
    printf ("The year that followed %d was %d.\n",year,year+1);
  }
  return 0;
}

Related Tutorials