Can't get simple loop to work

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jul 2007
Posts: 2
Reputation: intangir1999 is an unknown quantity at this point 
Solved Threads: 0
intangir1999 intangir1999 is offline Offline
Newbie Poster

Can't get simple loop to work

 
0
  #1
Jul 5th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,867
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 755
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Senior Bitch

Re: Can't get simple loop to work

 
0
  #2
Jul 5th, 2007
>"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.
New members chased away this month: 5
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 2
Reputation: intangir1999 is an unknown quantity at this point 
Solved Threads: 0
intangir1999 intangir1999 is offline Offline
Newbie Poster

Re: Can't get simple loop to work

 
0
  #3
Jul 5th, 2007
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.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 1143 | Replies: 2
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC