| | |
Compare Char[] to ""
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2005
Posts: 3
Reputation:
Solved Threads: 0
I'm having type problems... if anyone could help that'd be great. Also, I haven't coded in c++ for 2 years.. very rusty 
Ok, I have the following dynamic char array and code
Now, the error I get says I cant compare an int to a char... it appears that term1[1] is changing from a char to a small int.
What can I do to make this comparison work?
Thanks in advance!

Ok, I have the following dynamic char array and code
C++ Syntax (Toggle Plain Text)
char* term1; term1 = "f(x)"; //i really have a loop here... if ( term1[1] == "(" ) <------ Error here { //do stuff... }
Now, the error I get says I cant compare an int to a char... it appears that term1[1] is changing from a char to a small int.
What can I do to make this comparison work?
Thanks in advance!
double quotes mean a null-terminated string, single quotes is a single character. Replace the double quotes in the if statement to single quotes.
C++ Syntax (Toggle Plain Text)
if ( term1[1] == '(' )
![]() |
Similar Threads
Other Threads in the C++ Forum
- Previous Thread: Help with c++ program
- Next Thread: Making a MUD
| Thread Tools | Search this Thread |
add api array arrays based beginner binary bmp c++ c/c++ calculator char class classes code compile compiler console conversion count data delete deploy desktop directshow dll download dynamic encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib library linkedlist linker linux list loop looping loops map math matrix memory microsoft newbie news number output pointer problem program programming project python random read recursion recursive return simple string strings struct studio temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






