by Dinesh Thakur Category: Function and Pointer

Printf function always returns the number of characters printed by the printf function. Let us see this in brief with an example:


int a=10;
printf(“%d,printf(“%d %d %d,a,a,a));


In this above program the inner printf is first called which prints three times the value of a, with space between each value namely 10 10 10. So 5 characters namely 3 value of a namely 10 and 2 spaces which totals to 5 characters gets printed.
So as explained before the inner printf after printing the values returns the number of characters printed namely 5 which is printed by the outer printf .
The output of the above program is
10 10 10 5
So it is always that function returns a value and so is printf which returns the number of characters successfully printed.


About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles