I would greatly appreciate if someone could help with the following:

I am attempting to read in a fraction using scanf and store the numerator and denominator as integers. The following code that I have written captures most errors however if for example 1/2/3 is entered then I believed that scanf would not return 3 and therefore be caught. Not the case it still returns 3! Does anyone have any ideas?

Thanks in advance,

Paul

do

{

errorFlag=0;

printf("\n\nEnter a fraction:> ");

fflush(stdin);

x=scanf(" %i %c %i", &num1, &slash, &denom1);

if (x!=3 || slash!=47)

{

printf("Input must be of form A/B where A and B are both integers.");

errorFlag=1;

}

if (denom1==0)

{

printf("\nDenominator cannot be zero.");

errorFlag=1;

}

}

while(errorFlag==1);