top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

C: What is the return value of a printf function?

+4 votes
809 views
C: What is the return value of a printf function?
posted Nov 10, 2014 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+2 votes
Return the number of characters printed (excluding the null byte used to end output to strings).

For example:

int main()
{
    printf("Num of char printed : %d\n", printf("Hello!"));
    return 0;
}

Output : Hello!Num of char printed : 6

answer Nov 10, 2014 by Arshad Khan
It will print number of charecter printed by printf function
printf("Hello");
will return 5
Similar Questions
+1 vote

Say we have program like this

void main()
{
int a=10, b=20;
printf("%d %d");
}

above we are not providing a and b but program compiles and print some junk values.

Any explanation?

+3 votes
#include <stdio.h>
int main()
{
    char vowels[5]={'a','e','i','o','u'};
    int x;

    printf("Vowel Letters");
    for(x=0;x<=5;x++)
    {
         printf("\n %C",vowels[x]);
    }
}

Output

Vowel Letters
a
e
i
o
u
♣
Process exited after 0.1132 seconds with return value 3

What is the meaning of return value 3

+1 vote

Something that just sends a screen directly to the printer without having to involve Notepad or the like? I am unable to find a search function on the updated Yahoo group.

...