Hi Epoch.
hmm ok lets start with your variables....
You want the user to input some text but you are using an int variable to store it.
You should use a c string char *name, *password; or the string class <string> i recommend string class:
http://www.cplusplus.com/reference/string/
1 2
|
string name;
string password;
|
You are also missing some
break;
's in your loop fix that and some logical errors like
1 2 3 4 5
|
inFile >> name;
cout << "Choose a Name you would like to use and type exit to quit.\n";
cin >> name;
cout << " " <<endl;
cout << "\n" <<endl;
|
also:
|
inFile.open("C:\accountname + pw.txt");
|
if you want a '\' in your string you have to add 2 like
inFile.open("C:\\accountname + pw.txt");
i'm guessing the file name here is wrong too;
you might want something like this:
1 2 3 4 5
|
string fileName, accountName, fileExt;
fileExt ="pw.txt";
cin << accountName;
fileName = accountName + fileExt;
inFile.open(fileName.c_str());
|
take a look at the open mode's for the open function:
http://www.cplusplus.com/reference/iostream/fstream/open.html
consider checking if the file is actually open before using it:
1 2 3 4 5 6 7 8 9 10
|
if(inFile.is_open())
{
//use your file and then close it
//...
inFile.close();
}
else
{
cout << "error opening the file\n";
}
|
And some other errors, fix as many errors as you can and come back your new code and some compile errors(if any).
J