Hi all.

I can't get this to compile;

#include <iostream>
#include <string>
using namespace std;
 
int main ()
 
{
 
      int number;
      string response;
 
      for (number=5; response!='Y';)
     {
      cout <<number <<endl;
      cout <<"Had Enough (Y/N)?";
      cin>>response;
      }
 
cin.get ();
cin.get ();
 
return 0;
 
}

when i try to compile this message comes up:

no match for 'operator!=' in 'response!='Y''

What does this mean? What can i do to get it to work?

Any help would be greately appreciated.

Thanks

This does get it to compile.

Though whether i type N,n or Y,y it just continues to loop the question, never terminating.

Or
response !="Y"

When i do that it wont compile saying;

expected primary-expression before "char"

char response;

for (number=5; response!='Y' and response != 'y';)

Cheers - got it to work!!! - though response !='y' seemed to be redunant.

Now i'm playing around to figure out how to make it repeat the question if you just type return - though i have a fealing it is far to complex for me right now!

This question has already been answered. Start a new discussion instead.