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
Post a Comment