What will be the output of the following C++ code?#include #include using namespace std;int main () {int length;char * buffer;ifstream is;is.open ("sample.txt", ios :: binary );is.seekg (0, ios :: end);length = is.tellg();is.seekg (0, ios :: beg);buffer = new char [length];is.read (buffer, length);is.close();cout.write (buffer, length);delete[] buffer;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?<br>#include <iostream><br>#include <fstream><br>using namespace std;<br>int main () <br>{<br>int length;<br>char * buffer;<br>ifstream is;<br>is.open ("sample.txt", ios :: binary );<br>is.seekg (0, ios :: end);<br>length = is.tellg();<br>is.seekg (0, ios :: beg);<br>buffer = new char [length];<br>is.read (buffer, length);<br>is.close();<br>cout.write (buffer, length);<br>delete[] buffer;<br>return 0;<br>}