You have to copy the entire text file, leaving out the word you want to delete, and then delete the original Dictionary.txt file and rename the copy to Dictionary.txt
As an aside, this void main() is not C++ and this system("pause"); is expensive, dangerous and non-portable.
Write it. It's not difficult. You have to read each word in, and if it's not the word you want to delete, write it out again into the new file. Your code above already reads and writes files, so you shouldn't have any trouble.
The way you are doing it:
- Read each line from the file to a variable. At the end of the loop, you have the last line on this variable.
- Write to the file this single variable.
The way you should do it:
- Create a vector.
- Read each line from the file to a variable. Check if it is your word. If it's not, add it to the vector.
- Clear the file and write your vector to it.