Listing 2 this program ignores extraneous input, reports incorrect input, then continues execution until the user ignals and end-of-file.

#include <stdio.h>

#define MAXLINE 80

main()
{
    int n;
    char c, buf[MAXLINE+1];
    
    while (gets (buf))
       if (sscanf(buf,"%d , %c",&n, &c) == 2)
          printf ("%d, %c\n",n,c);
       else
          printf("Invalid input: \"%s\"\n",buf);
    return 0;
}
/* End of File */