954,487 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Can't get simple loop to work

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<'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!

intangir1999
Newbie Poster
2 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0
 

>"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.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

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.

intangir1999
Newbie Poster
2 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You