469,898 Members | 1,733 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

Need basic Boolean help..."ANSI C++ forbids comparison between pointer and integer"

I'm trying to code a simple function that will prompt a user if they want to see another set of problems. The error I receive is "ANSI C++ forbids comparison between pointer and integer"
Expand|Select|Wrap|Line Numbers
  1. int doAgain()
  2. {  
  3.   bool check;
  4.   char choice;
  5.   cout<<"Do you want to do another set of problems now?\n"
  6.       <<"Enter y(yes) or n(no): ";
  7.   cin>>choice;
  8.   check=(choice=="y"); 
  9. }
  10.  
I simply need the function to return a true or false...can "==" only be used when testing integers? If so how can I get the function to return a true for choice = Y or y?
Feb 14 '07 #1
1 5129
horace1
1,510 Expert 1GB
in the statement
Expand|Select|Wrap|Line Numbers
  1.   check=(choice=="y"); 
  2.  
"y" is a string and you cannot compare choice which is a char with it. try
Expand|Select|Wrap|Line Numbers
  1.   check=(choice=='y'); 
where 'y' is a char
Feb 14 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by maxim vexler | last post: by
18 posts views Thread by steve | last post: by
20 posts views Thread by chutsu | last post: by
8 posts views Thread by Simon Klein | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.