

#include <ctype.h> int isdigit(int c);
isdigit tests an integer value to determine whether it is a numeric
character (digit).
isdigit returns 0 if the character is not a digit, or a nonzero
value if it is. If the argument is EOF, 0 is returned.
isdigit on a noncharacter argument other than EOF
is undefined. Do not assume that isdigit returns either 0 or 1.
#include <ctype.h>
#include <stdio.h>
#define IDMAX 40
main()
{
char id[IDMAX+1];
char *text;
char input[IDMAX];
int i;
puts("Enter a string of numbers/characters (maximum 40):");
text = gets(input);
/* Copy a string of digits from text to id. */
for (i = 0; i < IDMAX && isdigit(text[i]); ++i)
id[i] = text[i];
id[i] = '0';
/* Only the digits should be copied. */
printf("You first entered these digits: %sn", id);
}
isxdigit
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.