Vignesh Jayavel

Hidden features of C - printf() and scanf() functions

Hidden features of C - printf() and scanf() functions

Did you know that printf() and scanf() function calls return values? Please read further to know about the hidden features of these most widely used functions! [code language=”cpp”] printf(“Hello!”); //returns integer value 6 i.e the no. of characters printf() prints on screen int i=10; printf(“%d”,i); //this would return 2 //scanf() behaves differently compared to printf() scanf(“%d”,&i); //say the input is 10. This would return 1, as only one variable is assigned an input char str[100]; scanf(“%d %s”,&i,&str); //this would return 2, as 2 variables are assigned [/code]