This program is "C:\test\program.exe":
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int choice;
cout<<" Which name to embrace?\n\n";
cout<<" - 1. Fight Club\n";
cout<<" - 2. Shawshank Redemption\n";
cout<<" - 3. Italian Job\n";
cin>> choice;
}
There's also a .txt file there named file.txt, "C:\test\file.txt\". Inside this .txt file is the following:
[Let us embrace those names!]
Fight Club =
Shawshank Redemption =
Italian Job =
Now. After "cin>> choice;" in the program, I want there to be code that uses fstream. The program is run and let's say
the user types in "1", referring to "Fight Club". The program will now go inside the .txt file, and put the number "1"
next to "Fight Club =". So, it would be: "Fight Club = 1".
If the program is exited and started again, it would ask the same question: "Which name to embrace," and if
the user again types "1", the program will go inside the .txt file, look for Fight Club and change the line from:
"Fight Club = 1" to "Fight Club = 2". So, each time the program is run and the user types in which name
to embrace, the program will raise the number that stands by the name. How is this done?
P.s I'm using CodeBlocks as a compiler and Windows XP Pro.