Hi,
I have some problems with syntax when i have this inside my code:
Code:string val; while(val != "1" && != "2"){ .... }
Hi,
I have some problems with syntax when i have this inside my code:
Code:string val; while(val != "1" && != "2"){ .... }
Well, so what in particular do you not want to equal "2"?
i get these syntax errors
C:\Program Files\Microsoft Visual Studio\MyProjects\44\44.cpp(16) : error C2059: syntax error : '!='
C:\Program Files\Microsoft Visual Studio\MyProjects\44\44.cpp(16) : error C2143: syntax error : missing ';' before '{'
We know.
You need to say what, in particular, you want to not equal 2. Right now you are saying that you don't want __________ to equal 2, but that doesn't help; you need to fill in the blank.
Here is the code so far for an easy phone book. While the string variable is not equal to either 1 or 2 i would like the program to loop the first phase of the options 1 or 2.
Code:#include <iostream> #include <fstream> #include <string> using namespace std; struct telefon{ string namn; string nummer; }; int main(){ string val; while(val != "1" && != "2"){ cout << "Enter 1 or 2 for either option..." << endl << endl; cout << "1." << '\t' << "login to Adams phonebook" << endl; cout << "2." << '\t' << "exit program" << endl << endl; cout << "Enter choice: "; getline(cin, val); if (val == "1"){ string pass; cout << "Welcome to Adams phonebook, please insert password to continue..." << endl << endl; cout << "password: "; getline(cin, pass); if(pass == "bajskorv"){} else{ cout << endl << endl << "worng password please try again..."; } } } if (val == "2"){ exit(1); } return 0; }
So the line
means "while val doesn't equal 1 and ____________ doesn't equal 2". You need to fill in the blank with the variable you want to not equal 2.Code:while(val != "1" && != "2")
thank you!!!! Silly me by doing such a miss !!!