C Programming - Library Functions - Discussion

Discussion Forum : Library Functions - General Questions (Q.No. 7)
7.
Can you use the fprintf() to display the output on the screen?
Yes
No
Answer: Option
Explanation:
Do like this fprintf(stdout, "%s %d %f", str, i, a);
Discussion:
15 comments Page 1 of 2.

Bhavani said:   8 years ago
It is a destination for warning message.

Kousi kan said:   1 decade ago
Actually I experimented, stdout used to print in output screen, fprintf used in file. Printf used in fun.

Rahul anantwar said:   1 decade ago
fprintf(fp, "abc....");

This statement writes the text in file pointed by fp pointer in d same way stdout is also a pointer that points to the output device hence.

fprintf(stdout, "abc");

This statement will print value on the screen or on any output device.

Ambica said:   1 decade ago
Stdout is a standard output. It is used to print the output.

Shruti said:   1 decade ago
What does stdout refers here? And why it is used here?

Priya said:   1 decade ago
Hi @Indu,

Output will be same, but the only difference is where it prints (i.e. location).

printf - prints the output on terminal.

fprintf - prints output in file, this file can be used for further calculations if necessary.

Indu said:   1 decade ago
Then what is the difference between printf and fprintf.

What will be the output if we give printf and what could be the output if it is fprintf?

I want to know the difference.

Prabhu said:   1 decade ago
printf("Hai friends\n"); //This will print output in stdout.

FILE *f=fopen("test.txt","w");
fprintf(f,"%s","HELLO"); // This will print the output in test.txt.

Krinta said:   1 decade ago
Stdout points to which default file ?

Cherry said:   1 decade ago
fprintf() prints data that only in particular file.


Post your comments here:

Your comments will be displayed after verification.