#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main ()
{
char str[]="1776ad";
int year;
if (isdigit(str[0]))
{
year = atoi (str);
printf ("The year that followed %d was %d.\n",year,year+1);
}
return 0;
}
a) You're not looping. Your only checking the first digit.
b) Your atoi'ing the entire string. You only need the digit part, which you have to find by looping.