Listing 1 This program allows us to separate input items by commas.

#include <stdio.h>

int main()
{
    int n;
    char c;

    while (scanf("%d , %c%*c",&n, &c) == 2)
       printf ("%d, %c\n",n,c);
    return 0;
}

/*
SAMPLE INPUT
----
123,a
123 , a
123
,
a
123a

SAMPLE OUTPUT
----
123, a
123, a
123, a
<program halts due to input error>
*/