What is return printf() and scanf() function | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is return printf() and scanf() function

6th Dec 2018, 6:49 AM
King AAA
King AAA - avatar
7 Answers
+ 3
Your question is a bit unclear, do you want to know about return, printf, and scanf? Or do you want to know the return values of prinf and scanf functions? In case it is the later, printf returns the number of characters it prints. scanf returns the number of items it has successfully read. int x, y; printf("%d\n", printf("abc\n")); printf("%d", scanf("%d%d", &x, &y)); Output is abc 4 2
6th Dec 2018, 7:15 AM
Kishalaya Saha
Kishalaya Saha - avatar
+ 3
You never said the word "type", and if you know the values, you know their types: integer for both.
6th Dec 2018, 7:48 AM
Kishalaya Saha
Kishalaya Saha - avatar
+ 2
printf() is an library function used to print the input stream scanf() is used fir user input from keyboard or keypad int x; scanf("%d",&x); printf("%d",x);
6th Dec 2018, 6:56 AM
MsJ
MsJ - avatar
+ 1
I have ask return type not value that will print or scan
6th Dec 2018, 7:43 AM
King AAA
King AAA - avatar
+ 1
Yes they both return integer but integer value= number of parameters it passed
6th Dec 2018, 12:51 PM
King AAA
King AAA - avatar
+ 1
I'm still confused; I did explain what they return in my first comment. Do you still have any questions then?
6th Dec 2018, 1:43 PM
Kishalaya Saha
Kishalaya Saha - avatar
0
Do you mean for what purpose the return value could be meaningfully used? Well, if it works properly, you could take input in a loop and only break that loop when the values are all read in properly, something like that. (scanf seems to be bit troublesome, there are a lot of homepages discussing the difficult points.)
6th Dec 2018, 2:05 PM
HonFu
HonFu - avatar