gpt4 book ai didi

c - 警告 : comparison between pointer and integer array

转载 作者:行者123 更新时间:2023-11-30 20:02:09 25 4
gpt4 key购买 nike

这些是我的代码的一部分。

struct identifier_structure
{
char identifier[30] ;
};

char read [30];

struct identifier_structure identifier_list [30] ;

if(strcmp(identifier_list[i].identifier,read) == 0 ||
identifier_list[i].identifier == read[0])

问题是警告:“指针和整数之间的比较”。
一切都是char类型,为什么我会出现指针和整数比较错误?

最佳答案

identifier_list[i].identifier==read[0]

转换后==运算符的左操作数为char *类型,右操作数为char类型。在 C 中不能比较指针和整数。

关于c - 警告 : comparison between pointer and integer array,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23406838/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com