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

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -