Hey it is very simple program. You have to just use isdigit() function to get only digits from an input string. isdigit() function is used to check if character is decimal digit or not. Just try to understand following example. It is very simple program.
Code:
/* isdigit example */
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main ()
{
char strs[]="17s76asd";
int years;
if (isdigit(strs[0]))
{
years = atoi (strs);
printf ("The year that followed %d was %d.\n",years,years+1);
}
return 0;
}
Bookmarks