#include <stdio.h>
#include <stdlib.h>
int main()
{
int i;
printf("digite um número %d",scanf("%d",&i));
}
The following program only gives result 1 and I do not understand why.
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i;
printf("digite um número %d",scanf("%d",&i));
}
The following program only gives result 1 and I do not understand why.
Because Scanf returns an integer with the number of entries.
scanf("%d",&i)
This will return the number 1
scanf("%d" "%d",&p,&i)
You will return the number 2 and so on.
If you put within while
, as follows:
while ( scanf("%d", &i) == 1)
It will be true. If you put
while ( scanf ("%d" "%d", &p, &i) == 2)
It will be true
too.
And so on.