Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I'm getting this warning on this code...what does it mean?
IntelliSense: operand types are incompatible ("char *" and "int")

RED = mysql_fetch_row(res_set);
		if (RED[i] == 1)
		{
			printf("PASS: %s\n",RED[i]);
		}
		else
		{
			printf("FAIL: %s\n",RED[i]);
		}


If I change it to this the warning goes away...
if (RED[i] == "1");


However the logic doesn't work. Is RED[i] returning a char* instead of an int?
Posted
Updated 14-May-11 5:35am
v3

I take it the complaint is here?
if (RED[i] == 1)
If so, then it makes sense: the type of RED[i] will be char* - try comparing it with "1" instead.
if (RED[i] == "1")


[edit]
Way too much C#! :laugh:

Try parsing RED[i] to an int and comparing that...

[/edit]
 
Share this answer
 
v2
Comments
Member 7766180 14-May-11 11:13am    
The RED[i] is coming to me as a char*
If I do "1" then the warning goes away but logic isn't executed.
If I do '1' then the warning says char* and char incompatible
The [i] is coming to me as a my_ulonglong data type from an online mysql database if that helps.
OriginalGriff 14-May-11 11:22am    
That's what I realized and why I edited my answer 1/2 hour ago! In C#, it would compare the two strings... :laugh:
If you use "1" then it compares two addresses, and they don't match.
If you use '1' the it compares an address to a char, and they can't match.
As I said, you need to parse the char* data to a int and compare that.
Use:
if (atoi(RED[i]) == 1)
Should do the trick!
Member 7766180 14-May-11 11:33am    
OMG X 3!!!!!!!! Your the HERO! This is unbelievable! After all of the nonsense yesterday it boiled down to one word! atoi Thank you so very much!
OriginalGriff 14-May-11 12:19pm    
You're welcome!
Albert Holguin 16-May-11 19:15pm    
good job, my 5
You are storing a string inside the RED variable...

You should not compare an integer (1) with a char RED[i]...

You should use if(RED[i]=='1')...

I don't know which language you are using... in your question you posted C++, but in the pre tag there's vb...

At the end you must compare char to char... not char to int...

HTH!
 
Share this answer
 
v4
Comments
Member 7766180 14-May-11 10:48am    
Did that. Now instead of getting a "1" or a "0" I get something like 31191408.
OriginalGriff 14-May-11 10:51am    
Joan, the "vb" bit will be automatic - the analyser defaults to that when you paste with the "auto detect" option on.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900