操作数类型不兼容("char *"和"int") [英] Operand Types Are Incompatible ("char *" and "int")

查看:2749
本文介绍了操作数类型不兼容("char *"和"int")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在此代码上收到此警告...这是什么意思?
IntelliSense:操作数类型不兼容("char *"和"int")

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?

推荐答案

我认为投诉在这里吗?
I take it the complaint is here?
if (RED[i] == 1)

如果是这样,那就很有意义:RED [i]的类型将为char *-尝试将其与"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]
太多的C#! :laugh:

尝试将RED [i]解析为一个int并将其进行比较...

[/edit]



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

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

[/edit]


您正在将字符串存储在RED变量中...

您不应该将整数(1)与char RED [i] ...比较.

您应该使用if(RED [i] ==''1'')...

我不知道您使用的是哪种语言...在您发布C ++的问题中,但是在pre标签中有vb ...

最后,您必须将char与char进行比较...,而不是char与int进行比较...

HTH!
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!


这篇关于操作数类型不兼容("char *"和"int")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆