我正在尝试检查指针是否指向某个字符。
例如:
#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;
}
但是我经常收到警告:警告:指针和整数之间的比较 if(*s=="a")
指针和整数可以进行比较吗?
有没有其他方法来解决这个问题?
我能否在不打印它的情况下找出 *s 指向的字母?