| | |
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 |
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count database delete deploy developer dll download dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph gui homeworkhelp iamthwee ifstream image input int java lib library linker list loop looping loops map math matrix memory multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg simple sorting string strings temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






