c++ - Only int input recognized is 1 -


no matter input, int recognized in function 1. if else selected, do-while loop repeats. code worked fine without or operators, e.g. "while (input != 0)"

void menu() {     int input = -1;         {     cout << "         ---------------" << endl << "         -     ou6     -" << endl << "         ---------------" << endl;     cout << "1. read transaction keyboard." << endl;     cout << "2. print transactions console." << endl;     cout << "3. calculate total cost." << endl;     cout << "4. debt of single person." << endl;     cout << "5. unreliable gold of single person." << endl;     cout << "6. list persons , fix." << endl;     cout << "0. save , quit application." << endl;     cin >> input;     } while (input != (0 || 1 || 2 || 3 || 4 || 5 || 6));      if (input == 0)     {         cout << "0!" << endl;         cin.get();     }      if (input == 1)     {         cout << "1!" << endl;         cin.get();     }      if (input == 2)     {         cout << "2!" << endl;         cin.get();     } } 

this line:

while (input != (0 || 1 || 2 || 3 || 4 || 5 || 6)) 

does not think does. can't combine tests this. have written equivalent while (input != true), , since true equal 1 can see option work input == 1.

you need change e.g.

while (input < 0 || input > 6) 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -