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.

Recommended Answers

All 6 Replies

try

char response = 'N';

.

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.

try

char response = 'N';

.

Or
response !="Y"

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';)

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.