944,152 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 1535
  • C++ RSS
Jul 5th, 2007
0

Can't get simple loop to work

Expand Post »
I am trying to write this loop in a simple convert process, but I get all sorts of crazy errors when I try using the "not equals" operators.

here is my code:

int main()
{
int i = 5;
std::string s;
do
{
cout<<" Enter a string: ";
cin>>s;
cout<<endl;
double x = converToDouble(s);
cout<<" The answer is " << x<<endl;
i--;
}while (s<>'q');
return 0;
}


The line before the "return 0", I try using "<>" and "!=", but both give me errors like "error C2059: syntax error '>' " and if I used "!=" then I get "...could not deduce template argument for 'const _Elem *' from 'char'"

Is there a certain library I need to include to use these compare operators?

I'm Using Visual C++ 2005 Express.

Thanks!
Last edited by intangir1999; Jul 5th, 2007 at 2:27 pm.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
intangir1999 is offline Offline
2 posts
since Jul 2007
Jul 5th, 2007
0

Re: Can't get simple loop to work

>"error C2059: syntax error '>' "
<> doesn't mean "not equal to". You want the != operator.

>"...could not deduce template argument for 'const _Elem *' from 'char'"
String literals use double quotes and character literals use single quotes. Try s != "q". Of course, I would be a little suspicious of your logic because even if the string is "q", you still convert and print it.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Jul 5th, 2007
0

Re: Can't get simple loop to work

Thanks! That definitely got it! I can't recall that I needed to use the double quotes for strings but I guess I'm so used to the single quotes that I forgot about that.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
intangir1999 is offline Offline
2 posts
since Jul 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: iterator deref problem
Next Thread in C++ Forum Timeline: Several C++ Designing Questions





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC