How do you edit a text file in c++, I know how to open and view files, but not edit them.
Thank you.
How do you edit a text file in c++, I know how to open and view files, but not edit them.
Thank you.
- Read in the text
- make some changes (say search and replace)
- write the file
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
You don't "edit" text files in C++, per se. You would read it, modify the content, then completely re-write the file.
A quick google search turned up some promising results: C++ file i/o tutorial - Google Search