I have the following code lines :
printf("enter a number: \n");
if (scanf("%d", &x) == 1)
{ //do some stuff}
else {return 1;}
printf("enter another number: \n");
if (scanf("%d",&y) == 1)
{ //do some stuff}
else {return 1;}
the code works but when I'm putting an input to x in the following form "1 1" (1 then space then 1 again) it put the 2nd 1 into y. How can I make it won't happen? it should just stop the code.
I know there are other methods to get inputs but as for now, I'm only allowed to use scanf to get input from the user.