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

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!

3
Contributors
3
Replies
4
Views
12 Years
Discussion Span
Last Post by ITgeneration
0

double quotes mean a null-terminated string, single quotes is a single character. Replace the double quotes in the if statement to single quotes.

if ( term1[1] == '(' )
0

Ha and it was easy as that :)

soooo used to vb... i'm regressing.. haha

Thanks a million and for the quick response!
:cheesy:

0

AOA
note that every c and c++ Singly character in singal qutaion markes
just like 'a' , '(' and any other
and a string is Double Qutaion markes just like "me" , "String" ,"this is a example" ok
:eek: ALLAH HAFIZ

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.