Hi I am working on my assignment where I have to create a database(text file) depending on user entries. An option in the front menu of my program is to provide a "modify" option to the user.
My issue is when I open my text file to compare the user entry with my text file entry I get a invalid null point error.
Here is my code.
Any help would be appreciated.
Assuming I make the call to my function "newName" from a nested switch statement, switchcase ...
void newName(string M, string O) // M = account number, O = New Name
{
string newname = O;
cout << "new name is" << newname;
ifstream in_file;
in_file.open("Accounts.dat"); //open the file
if (in_file.fail())
{
cerr << " Error Opening File" << endl;
exit(1);
}
constchar* const DELIMITER = ";";
constchar* const DELIMITER1 = "+";
constint MAX_TOKENS_PER_LINE = 50;
constint MAX_CHARS_PER_LINE = 512;
constchar* token[MAX_TOKENS_PER_LINE] = {}; //
while (!in_file.eof()) //read until we reached the end
{
char buf[MAX_CHARS_PER_LINE];
in_file.getline(buf, MAX_CHARS_PER_LINE);
string S1 = buf;
token[0] = strtok(buf, DELIMITER);
if (token[0] == M)
{
string Newname;
cout << "Account Match Found"<<endl;
break;
}
}
in_file.close();
}