What is the output of this C++ program in the "test.txt" file?
#include <fstream>
using namespace std;
int main ()
{
long pos;
ofstream outfile;
outfile.open ("test.txt");
outfile.write ("This is an apple",16);
pos = outfile.tellp();
outfile.seekp (pos - 7);
outfile.write (" sam", 4);
outfile.close();
return 0;
}
#include <fstream>
using namespace std;
int main ()
{
long pos;
ofstream outfile;
outfile.open ("test.txt");
outfile.write ("This is an apple",16);
pos = outfile.tellp();
outfile.seekp (pos - 7);
outfile.write (" sam", 4);
outfile.close();
return 0;
}A. This is an apple
B. apple
C. sample
D. This is a sample
Answer: Option D

Join The Discussion