可能重复:
在 C 语言中,char s[] 和 char *s 有什么区别?
在 C 语言中,char s[] 和 char *s 有什么区别?
下面是一个程序:
#include<stdio.h>
int main()
{
char str[20] = "Hello";
char *const p=str;
*p='M';
printf("%s\n", str);
return 0;
}
这将打印Mello作为答案。但是由于p是一个常量指针,它不应该出现错误。