I have following text file

Ram Shaym Rahul
Radha Madhuri Sita

I want to read this file and create new file from this file showing following change

Ram Shyam Rahul
Radha Sridevi Sita

I want to replace Madhuri by Sridevi and send output in output.txt

Can anyone please help me

Recommended Answers

All 3 Replies

Can you read the values in and write them back out again? Start there if you can't.

Yes Means by using fstream and getline, I can able to read and write file.

But replacing words in existing file and writing in output file is a main concern.

Please send me a little program for my above problem.

I won't send you a program. It's against the forum rules, and besides, this is your assignment.

Now, so you've got a good start with getline. After you've read in a line, check it to see if the string you are looking for is contained in it. If not, immediately write the line out to the file. If so, modify the line and write it out.

Be a part of the DaniWeb community

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