char *str1 = "hello";
char str2[] = "hello";
if (str1 == "hello")
printf("ok1\n");
if (str2 == "hello")
printf("ok2\n");
if (strcmp(str1, "hello"))
printf("ok3\n");
if (strcmp(str2, "hello"))
printf("ok4\n");
一道基础题,知道 ==比较地址,strcmp比较内容。
请各位大神指教为何输出的是 ok1 谢谢!