0

What I want to do

In file,

username MyName
username MySecondName

the file I want

username Michale
username MySecondName

I want to change "MyName" to other string, like "Michale".

I try to use regexr and wfstream, and overwrite "Michale" at the wstreampos of MyName.

there is no problem when other string is longer than "MyName".

Fisrt problem : Remains when overwrite

But if other string is shorter than "MyName", like "Mike", the problem is

username Mikeme
username MySecondName

There are remaining letters behind!

Second problem : New line

To solve first problem,

streamout << "\n" ;
//or streamout << std::endl;

That's not a result I want

username MyName

username MySecondName

please let me know how to change, trim and print string in file.

0 Answers0