1int isdigit ( int c );
2Checks whether c is a decimal digit character.
3
4A value different from zero (i.e., true)
5if indeed c is a decimal digit. Zero (i.e., false) otherwise.
6
7
8/* isdigit example */
9#include <stdio.h>
10#include <stdlib.h>
11#include <ctype.h>
12int main ()
13{
14 char str[]="1776ad";
15 int year;
16 if (isdigit(str[0]))
17 {
18 year = atoi (str);
19 printf ("The year that followed %d was %d.\n",year,year+1);
20 }
21 return 0;
22}
23
24/* Output */
25The year that followed 1776 was 1777
1#include<stdio.h>
2#include<ctype.h>
3
4int main() {
5 char val1 = 's';
6 char val2 = '8';
7
8 if(isdigit(val1))
9 printf("The character is a digit\n");
10 else
11 printf("The character is not a digit\n");
12
13 if(isdigit(val2))
14 printf("The character is a digit\n");
15 else
16 printf("The character is not a digit");
17
18 return 0;
19}