|
|
发表于 2006-9-12 15:06:12
|
显示全部楼层
俺也贴个初级代码,请大牛帮忙分析。在strncpy那里老是Segmentation fault,line_content肯定超过10个字符长。
[php]
char *person_name;
int main(int argc, char *argv[])
{
char *buf="/tmp/group.txt";
FILE *info;
char line_content[256];
char *temp;
info=fopen(buf, "r");
if(info){
fgets(line_content, 256, info);
temp=line_content;
strncpy(person_name, temp, 10);
}
}[/php]
我去掉temp=&line_content;里的&了。还是在strncpy出现Segmentation fault错误 |
|