- 論壇徽章:
- 0
|
我寫(xiě)的一段程序如下:
FILE *fp;
char rdbuf[256];
long cnt=0;
char *p;
if ((fp=fopen(MESSAGES_NAME,"r+" )==NULL)
{
printf("open file error\n" ;
return;
}
while (!feof(fp))
{
if(fgets(rdbuf,256,fp)==NULL)
{
printf("finished\n" ;
break;
}
cnt++;
if(strstr(rdbuf,who)!=NULL)
{
int len=strlen(rdbuf);
char *set;
char *p;
p=strstr(rdbuf,who);
printf ("please input the module name u want to insert\n" ;
scanf("%s",set);
strcpy(p,set);
fseek(fp,-len,1);
fputs (rdbuf,fp);
fseek(fp,len,1);
}
}
fclose(fp);
但是提示sementation fault,
請(qǐng)高手指教! |
|