| | |
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:
Solved Threads: 0
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!
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.
>"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
<> 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
![]() |
Similar Threads
- Java's String Tokenizer (Java)
- nested for loop problem (Java)
- trying to make a "Do While" loop; loop (C++)
- For loop (C++)
- My loop won't work, but I'm positive it should. (Python)
- Help with gui loop. (C)
Other Threads in the C++ Forum
- Previous Thread: iterator deref problem
- Next Thread: Several C++ Designing Questions
Views: 1143 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api array arrays based beginner binary bmp c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete deploy dll download dynamic encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib library lines linker list loop looping loops map math matrix memory microsoft newbie news number output pointer problem program programming project python random read recursion recursive reference return simple sort spoonfeeding stream string strings struct temperature template templates test text text-file tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets






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. 