This shows you the differences between two versions of the page.
c:ctype.h:isdigit [2013/01/22 22:02] |
c:ctype.h:isdigit [2024/02/16 01:05] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | {{keywords>wiki library source code example reference}} | ||
+ | ====== isdigit ====== | ||
+ | <code c> | ||
+ | int isdigit(int chr); | ||
+ | </code> | ||
+ | |||
+ | tests if a character a digit | ||
+ | |||
+ | ===== C Sourcecode Example ===== | ||
+ | <code c> | ||
+ | #include <stdio.h> /* including standard library */ | ||
+ | //#include <windows.h> /* uncomment this for Windows */ | ||
+ | |||
+ | #include <ctype.h> | ||
+ | |||
+ | int main ( void ) | ||
+ | { | ||
+ | int i; | ||
+ | char string[11]="Test\n-!&%1"; | ||
+ | for (i=0; i <= 11;i++) | ||
+ | { | ||
+ | if ( isdigit(string[i]) != 0 ) | ||
+ | { | ||
+ | printf("Character %i is a digit\n",i); | ||
+ | } | ||
+ | } | ||
+ | return 0; | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | ==== output ==== | ||
+ | user@host:~$ ./isdigit | ||
+ | Character 9 is a digit | ||