I've been working on that "contact list" on and off now, and now I'm really trying to get it complete.
I'm trying to reduce the clutter right now, and make it more readable. All the braces and if, else statements are getting pretty big, so I tried putting them in functions.
I declared it, called it and defined it properly ( I hope) but it doesn't seem to be working. The program Compiles fine, no errors or warnings. But when the time comes to call the function, it doesn't call for some reason.
[CODE=cpp]string option_one(){
string pass1, pass2;
cout << "\n\n\t Enter your new password:.";
cin.ignore();
getline(cin, pass1);
cout << "\n\n\t Enter your new password once more (Verification Purposes):.";
cin.ignore();
getline(cin, pass2);
if (pass1 == pass2){
Realpass = pass1; //Realpass is defined globally
cout << "\n\n Password has been changed successfully! ";
}
if (pass1 != pass2){
cout << "\n\n The two passwords did not match :'[ ";
}
return 0;
}
[/CODE]
Can a function just be made of a bunch of ifs, else, couts and getlines ?
My guess is, that there's no such thing as a string function? I tried even using a void function, but I get the same results.
I also understand that this function is pointless since it doesn't actually store the new Realpass into a file, but I'll get that tackled sooner or later. Right now, I just want to get the menus set up correctly.
I apologize for the trouble.
I'm trying to reduce the clutter right now, and make it more readable. All the braces and if, else statements are getting pretty big, so I tried putting them in functions.
I declared it, called it and defined it properly ( I hope) but it doesn't seem to be working. The program Compiles fine, no errors or warnings. But when the time comes to call the function, it doesn't call for some reason.
[CODE=cpp]string option_one(){
string pass1, pass2;
cout << "\n\n\t Enter your new password:.";
cin.ignore();
getline(cin, pass1);
cout << "\n\n\t Enter your new password once more (Verification Purposes):.";
cin.ignore();
getline(cin, pass2);
if (pass1 == pass2){
Realpass = pass1; //Realpass is defined globally
cout << "\n\n Password has been changed successfully! ";
}
if (pass1 != pass2){
cout << "\n\n The two passwords did not match :'[ ";
}
return 0;
}
[/CODE]
Can a function just be made of a bunch of ifs, else, couts and getlines ?
My guess is, that there's no such thing as a string function? I tried even using a void function, but I get the same results.
I also understand that this function is pointless since it doesn't actually store the new Realpass into a file, but I'll get that tackled sooner or later. Right now, I just want to get the menus set up correctly.
I apologize for the trouble.
Comment