how I can modify the ofile object of fstream library, and the remaining data remain save as it was. e.g

ofile: hello world name class

this is the data ofile have and in modification i want to replace the name with "roll number". after modification ofile became

ofile: hello world roll number class

can anybody help me?

Recommended Answers

All 2 Replies

Text files can not be changed directly. Read the file into memory, make changes in memory, then rewrite back to the file.

thanx, the answer is helpful.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.