this is my code i can't get the function to pass back the string usrname, i don't even think that i did the pointers right...... i have been messing with it for days so it might be a little screwy.
plz help me.
int GetChar(string& usrname, int& CharLvl)
{
char usr[60];
char pass[60];
char temppass[60];
char *user;
user->usrname;
cout << "Enter 'new' for New Character!" << endl;
cout << "Username: ";
cin.getline(usr, 60, '\n');
if(strcmp(usr, "new") == 0)
{
cout << "What is the username you wish to use: ";
cin.getline(usr, 60, '\n');
ofstream b_file(usr, ios::noreplace | ios:ut );
if( !b_file ) {
cout << "Username In use pick a new name.\n";
return 1;
}
cout << "What password you wish to use: ";
cin.getline(pass, 60, '\n');
b_file << pass << endl;
b_file.close();
usrname = &usr[60];
return 0;
}
cout << "Password: ";
cin.getline(pass, 60, '\n');
ifstream a_file(usr);
if (!a_file )
{
cout << "Username not found.\n\n";
return 1;
}
a_file.get(temppass, 60, '\n');
a_file.close();
if( strcmp(temppass, pass) != 0 )
{
cout << "Invalid Username and or Password!\n\n";
return 1;
}
strcat(usrname, user);
cout << usr << endl;
cout << usrname<< endl;
return 0;
}