【发布时间】:2013-12-02 22:49:40
【问题描述】:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[]) {
char *str = "This is a string!";
int therealthing = sizeof(str[0]) * 4;
memset(str, 'b', therealthing);
printf("%s\n", str);
return 0;
}
此代码导致段错误,有什么想法吗? 我已经尝试将它作为内存地址和指针传递。
【问题讨论】:
标签: c segmentation-fault memset