C++, cin until no more input on line using a while loop -


i having issue c++ program. reformat , display words user enters console. if user enters : hi bob.the user press enter after entering bob console. reformat , reprint in it's new format. problem not want display message more input until of words on console line input. current loop have either displays request input after each word, or not display @ all. depends on whether or not include prompt or not. need make while loop process each word , output , stop after last word. boolean param that? including code reference.

int _tmain(int argc, _tchar* argv[]) {      int b;     string input;     string output ;     int check = 1;      while (check){         cout << "enter in 1 or more words output in rot13: " << endl;         cin >> input;         while(my issue here){              const char *word = input.c_str();              (int = 0; < input.length(); i++){                  b = (int)word[i];                 if (b > 96){                     if (b >= 110){                         b = b - 13;                     }                     else {                         b = b + 13;                     }                      output += ((char)b);                 }                  else                 {                     if (b >= 78){                         b = b - 13;                     }                     else {                         b = b + 13;                     }                      output += ((char)b);                 }                    }              cout << output << endl;             output = "";             cin >> input;          }              check = 0;      }      return 0; } 

you may replace entire while loop line:

std::getline(std::cin, input);  // input std::string 

and reformatting after line.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -