What is the best way to read a .txt file, modify it, and then replace the original with the new one in C++? [duplicate]

  c++, file, txt, vector

Basically, I want to be able to have a bunch of values on a txt file that can be changed so the next time I run the program, the txt file starts with the new values. My guess would be to 1. use a vector to copy all values from the txt file, then 2. change the vector values and finally 3. replace or edit the original txt file. I do not know how I would do the last step.

Source: Windows Questions C++