64,281
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
int main()
{
char *s="Golden Global View";
char *p=s;
p+=10;
*p ='\0';
printf("%s\n",s);
return 0;
}
#pragma comment(linker,"/SECTION:.rdata,RW")
//加这句可以让常量区可写。后果自负!
#include <stdio.h>
int main()
{
char s[20]="Golden Global View"; //Golden Glo
char *p=s;
p = p+10;
*p ='\0';
printf("%s\n",s);
return 0;
}
这么就行了,如果使用char s*,可以理解为const的。所以不可以直接通过*p来直接修改
#include <stdio.h>
int main()
{
char s[]="Golden Global View";//改成这样。。
char *p=s;
p+=10;
*p ='\0';
printf("%s\n",s);
return 0;
}