How to use isdigit() function to check whether a character is a digit in C

1 Answer

0 votes
#include <stdio.h>
#include <ctype.h>
 
int main(void)
{
    char s[] = "Unreal Engine 4 - DirectX 12";
	int i = 0;
	
	while (s[i])
	{
		if (isdigit(s[i])) 
			printf("%c is digit\n", s[i]);
		i++;
	}
    return 0;
}
 
  
/*
    
run:
    
4 is digit
1 is digit
2 is digit

*/

 



answered Jan 28, 2016 by avibootz
edited Jan 29, 2016 by avibootz
...