Answer to Question #179896 in C++ for Lav kumar

Question #179896

Write a program in C++ to open and read the contents of the Text1.txt using the file stream class. 

Close the file and again open to update the contents of given file Text1.txt.

Text1.txt : I am enjoying learning OOPS concepts

After update 

Text1.txt: I am enjoying learning OOPS concepts

 Now learnt C++; Java is my next target.


1
Expert's answer
2021-04-10T01:13:24-0400
#include <iostream>
#include <fstream>
using namespace std;


int main () {
  ofstream myfile;
  myfile.open ("Text1.txt");
  myfile << "Now learnt C++; Java is my next target.\n";
  myfile.close();
  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS