c++ - Input leter with number into if statement -
how can make if user enters, p(any number) still enters if statement below.
if ( input =='p') { ..... }
do have change in if statement?
basically if enter value p number following such p4 or p2, go if statement.
let's you've defined "input" c string, this:
char input[8]; fgets (input, 8, stdin);
in case, can check "begins p" this:
if ( input[0] =='p') { ..... }
the same syntax work if instead defined "input" std::string:
string input; cin >> input; if ( input[0] =='p') { ..... }
Comments
Post a Comment