-1

I want to replace dates in a line in a .txt file.

The line might look like this:

1234    24.08    24.09.

Can I find this line by just searching for 1234 and replace the dates 24.08 and 24.09?

admdrew
  • 3,790
  • 4
  • 27
  • 39

1 Answers1

1

If your replacement has the same quantity of characters as the text in the file, then go ahead and seek to the position and overwrite the text (see std::ostream::seekp).

Otherwise, you will have to write to a new file.

Files can't expand in the middle.

Thomas Matthews
  • 56,849
  • 17
  • 98
  • 154