It has been a while since I have done any C++ programming so I am a little rusty. I am trying to do a simple while(cin) loop to read in each word of the users input and then exit back to the main menu. To simplify things, I tried creating a while loop in a new cpp to rule out any other possible problems. heres what I got:
when I compile the code, the program stays in the while loop; it doesn't hang because it responds to any additional input I give it, but it does not ever output " out" as I would like. Ultimately I would like this program to take an input from the keyboard like "test1 test2" and output "test1* test2* out".Code:#include <stdio.h> #include <iostream> #include <fstream> #include <string> using namespace std; int main() { char string1[64]; while (cin >> string1) { cout << string1 << "* "; } cin.clear(); cout << " out"; return 0; }



LinkBack URL
About LinkBacks



