c++ - how to get a specific character from input? -


i done tutorial getchar: getchar - c++ tutorial

this worked till wanted make modifications.

char c; puts("enter . exit"); do{     c=getchar();  } while (c != '.'); {      if(c == 's'){         upgradeone();         cout << "upgrade1 done" << endl; }      if (c == 'a'){         upgradetwo();         cout << "upgrade2 done" << endl;     } }  while (total < 999){     total += i;     cout << total << endl; } 

i want use specific methods when user input equels specific character. if user types method upgradetwo() must activated. how supposed this?

the repetitive processing of input takes place in do...while loop. loop left when '.' pressed.

if want react on specific chars, have move if(c==...) statements loop (i.e. between getchar() , while).


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -