#include
#include
int main()
{
char *res1 = strstr("xxxhost: www.baidu.com", "host");
if(res1 == NULL)
printf("res1 is NULL!\n");
else
printf("%s\n", res1);
const char *res2 = strstr("xxxhost: www.baidu.com", "cookie");//疑问
if(res2 == NULL)
printf("res2 is NULL!\n");
else
printf("%s\n", res2);
return 0;
}
//运行结果是
host: www.baidu.com
res2 is NULL!
但是为什么,我将const char res2 改成char *res2编译就报错。
error: invalid conversion from 'const char' to 'char*' [-fpermissive],
第一个不也是正常吗?实在没想明白