这是因为char *s="Golden Global View";定义使字符串指针s指向常量字符串"Golden Global View",而接下来的语句memset(s,'G',6)试图改变指针s指向的值(常量字符串),常量不能改变的,所以出错。
你改成这样:
#include <string.h>
int main()
{
char s[]="Golden Global View";
memset(s,'G',6);
printf("%s",s);
return 0;
}
或者下面这样都可以的:
#include <string.h>
#include <stdlib.h>
int main()
{
char *s;
s = (char *)malloc(sizeof("Golden Global View")+1);
strcpy( s,"Golden Global View" );
memset(s,'G',6);
printf("%s\n",s);