for the program i am currently working on, i a situation similar to this:
1 2 3 4
string word;
cin word
while (word!="enter nothing")
{cin word;}
if that makes sense. basically i need to exit the while statement by entering in nothing when it asks me to input word. how would you do that? ive tried while (word!="") and while (word!=null) but all it does when i hit enter is continue waiting for me to input something
thanks!
............
cout<<"Enter a word that you would like to claim (000 to end)"<<endl;
cin>>claimed;
int counter=0;
findwords ();
while (claimed!="000"){ //loops claimed words search until you type 000
found=0;
...........................
cin>>claimed; }
...............
and i wanna change it to this:
1 2 3 4 5 6 7 8 9 10 11 12
cout<<"Enter a word that you would like to claim (000 to end)"<<endl;
//cin>>claimed ***tried it both with and without this here**
int counter=0;
findwords ();
while (cin>>claimed){ //loops claimed words search until you type 000
found=0;
.................
cin>>claimed;
}
Well that while loop will continue looping until you enter bad data, which is what I thought you wanted to do. If you want to do it that way, you will have to check the string the way you were originally, just use getline() instead of cin>> to get into the string.