I have an if statement that is supposed to check if the user entered exactly 4 arguments separated by a var like the following: param1,param2,param3,param4 . Problem is that it doesn't return an error if the user gives more than 4 inputs. It only returns an error when he gives less than 4.
char input[60];
char a1[42], a2[42], a3[42], a4[1];
printf("Enter info");
fgets(input, 60, stdin);
if (4 != sscanf(input,"%1[^,\n], %1[^,\n], %1[^,\n], %[^,\n]",a1, a2, a3, a4)) {
return printf("Error"),1;
}
else
{
printf("In");
}
I can't seem to find why. Thanks for your help