I wrote the following code:
#include <stdio.h>
int main()
{
int a, b;
printf("Enter values of a and b\n");
scanf(" %d%d ", &a, &b);
printf("a = %d b = %d\n", a, b);
return 0;
}
The program starts like this:
aps120797@XENON-PC:/mnt/d/Codes/LetUsC$ ./a.out
Enter values of a and b
1
2
3
a = 1 b = 2
My question is why it uses three inputs instead of two (two% d is in scanf ()), and even if it takes three, why does it skip the last?
source
share