• Tutorials
  • Courses
  • Tracks

Q2

Last Updated :
Discuss
Comments

 What does the following code do?

C++
ofstream file("data.txt", ios::app);
file << "Hello World\n";
file.close();


Creates a new file and writes data.

Overwrites the file contents.

Appends data to the file without deleting existing content.

Reads data from the file.

Share your thoughts in the comments