<分区>
我正在尝试检查指针是否指向某个字符。
像这样:
#include<stdio.h>
#include<string.h>
#define a 3
int func(char *);
int main()
{
char *s="a";
int type;
type=func(s);
printf("%d",type);
return 0;
}
int func(char *s)
{
int type;
if(*s=="a")
{
type=1;
}
return type;
}
但我不断收到警告:警告:指针和整数之间的比较 如果(*s==“a”)
是否可以比较指针和整数?
还有其他方法可以解决这个问题吗?
我可以在不打印的情况下找出哪个字母指向 *s 吗?