Passing char* to function ruins data?
Here's a project I just took off of the "waiting to die" pile. It is a super-simple money-managing program that reads data line-by-line from a txt file. Everything is Shibby except for when the name of the current account is read in. It is read just fine, however, when I pass it to the label(char*) function, it dies. I cannot display the char* in the label function without an error. Here's the name-reading portion of the code and the account label function.
Code:
case NAME:
{
Reader.getline(buffer, 55);
if(Reader.eof())
{
active = false;
break;
}
cout << "DEBUG: Buffer at case <name> <ReadInAccounts()>:" << buffer << endl;//works
CurrentAccount.label(buffer);//Error at this call
SaveAccount(CurrentAccount);
read_state = MONEY;
}break;
Code:
int ACCNT::label(char *InputName)
{
if(isnamed)
name = InputName;
else
{
name = InputName;
isnamed = true;
}
//cout << "DEBUG: name passed into <label()>" << InputName << endl;//DEBUG... causes a crash
//cout << "DEBUG: account name at <label()>: " << name << endl;//DEBUG... causes a crash
return 0;
}
I'll note also, that if later in the program (after all of the data is read in) I try to access the name of the account, it is simply a blank string.