C++/How to edit a certain position in a text file using C++
I was wondering how do you find a certain word or line that I want in a text file and then replacing it with another word or line.
I have a text file that contains:
[Printer number 3]
[Scanner number 15]
How do I change "Scanner number 15" to "Scanner number 10", or change "Enable=1" to "Enable=0"?
I know the basics for opening, closing, reading, and writing text files. I just need to know how to write to specific locations in my text. I tried searching for answers, and member functions such as tellp(), tellg(), seekg(), and seekp() came up, but I'm not really sure if they are needed or how they work.
Your help is much appreciated.
One method is read a word using get() function setting ''for delim from the file. Compare it with word. If it matches with the word then move the file pointer to the location of the word and write the word to be replaced. Please, let me know whether it answers your question