What will be the output of the following C++ code in text files?#include int main (){char buffer[BUFSIZ];FILE *p1, *p2;p1 = fopen ("myfile.txt", "w");p2 = fopen ("myfile2.txt", "a");setbuf ( p1 , buffer );fputs ("Buffered stream", p1);fflush (p1);setbuf ( p2 , NULL );fputs ("Unbuffered stream", p2);fclose (p1);fclose (p2);return 0;}

🎲 Try a Random Question  |  Total Questions in Quiz: 112  |  🧠 Study this quiz with Flashcards
This question is part of a full practice quiz:
C++ Programming Practice Test: Strings, Streams & Numerics in C++ — practice the complete quiz, review flashcards, or try a random question.

C++ quiz on basic strings and their characters, I/O streams, file and string streams, standard library and mathematical applications like numeric limits, file handling, vector arithmetic and random numbers. Strings: A string in C++ is a sequence of characters. It is a data type that is used to store text. Strings are declared using the string keyword.  Strings can be concatenated using the + operator.  Strings can be compared using the ==, !=, , = operators.  Streams: A stream in C++ is a sequence of characters that can be read from or written to. Streams are used to input and output... Show more

What will be the output of the following C++ code in text files?<br>#include <stdio.h><br>int main ()<br>{<br>char buffer[BUFSIZ];<br>FILE *p1, *p2;<br>p1 = fopen ("myfile.txt", "w");<br>p2 = fopen ("myfile2.txt", "a");<br>setbuf ( p1 , buffer );<br>fputs ("Buffered stream", p1);<br>fflush (p1);<br>setbuf ( p2 , NULL );<br>fputs ("Unbuffered stream", p2);<br>fclose (p1);<br>fclose (p2);<br>return 0;<br>}