+ 1

what will this printf print ?

int a; printf("%d",scanf("%d",&a)); //it displays 1 irrespective of input and it would be really helpful if anyone could explain this

4th Feb 2018, 8:57 AM
‎ ‏‏‎Anonymous Guy
1 Answer
+ 5
scanf() returns the number of inputs taken successfully. In this case, scanf() takes 1 variable, i.e. a as input. So it will return 1. EDIT: This link may be helpful https://stackoverflow.com/questions/10469643/value-returned-by-scanf-function-in-c
4th Feb 2018, 9:12 AM
DAB
DAB - avatar