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?
Answer: Option
Explanation:
Do like this fprintf(stdout, "%s %d %f", str, i, a);
Discussion:
15 comments Page 1 of 2.
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.
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.
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.
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.
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.
FILE *f=fopen("test.txt","w");
fprintf(f,"%s","HELLO"); // This will print the output in test.txt.
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.
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.
Kousi kan said:
1 decade ago
Actually I experimented, stdout used to print in output screen, fprintf used in file. Printf used in fun.
Ambica said:
1 decade ago
Stdout is a standard output. It is used to print the output.
Sri said:
1 decade ago
What is the difference between printf() and fprintf()?
Shruti said:
1 decade ago
What does stdout refers here? And why it is used here?
Cherry said:
1 decade ago
fprintf() prints data that only in particular file.
Bhavani said:
8 years ago
It is a destination for warning message.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers