I am writing this program where I read in a line of text. I am able to enter the text just fine and it stores okay, but then when I go to prompt user for another entry (such as an integer) I get an infinite loop because it is waiting for a valid entry. example: cout << "please enter a string of characters."; cin.getline(tempstringgoeshere, BUFFER); int selection = 0; while(selection < 1 || selection > 5) { cout << "Please make a selection:"; cin >> selection; // DOES NOT LET ME ENTER ANYTHING HERE - GOES PAST } Suggestions? Thanks, G
Spherelin
Posts
-
cin causes infinite loop in my program -
using an ADT object [modified]okay thanks - that fixed it! hey so if I am entering a number via a statement like: cin >> selection how do I clear cin for the next use. basically, user is going to enter a number (text entry program...for now). and then the next entry is going to be characters - like a name or state. Right now, it seems to take the strike of the return key as the second entry. THanks, G
-
using an ADT object [modified]I am working on a C++ class project in MSVC. I have declared: class Node { private: . . . public . . . }; now in a separate file, I want to declare: class Employee { private: Node alphabetagamma; // for example . . public: . . . }; When I do this I get compile time errors indicating that the compiler does not recognize "Node" as a type of object. I am including the header files correctly in my implementation (.cpp) files. What am I forgetting? Thanks, Geoff:(( -- modified at 5:02 Friday 1st December, 2006