[juliantec_list] 请帮忙看看这段程序为什么老是报告段错误

  • From: hetao21182 <hetao21182@xxxxxxx>
  • To: app-dev-in-linux@xxxxxxxxxxxxxx
  • Date: Fri, 21 Oct 2011 09:54:32 +0800 (CST)

大家好:
     昨天我的一个函数,用来过滤文件中某些内容的。
为什么老是出现 segment fault???

void del(FILE *fp1,FILE *fp2,char *str1){  char str2[500];  long int size;  
memset(str2,0,500);  fseek(fp1,0,SEEK_END);  size=ftell(fp1);  
fseek(fp1,0,SEEK_SET);  while(!feof(fp1))   {     fgets(str2,size,fp1);     
if((strstr(str2,str1))!=NULL)       {         continue;        }     
fputs(str2,fp2);   }    fclose(fp1);    fclose(fp2);}

在 while 循环中,也就是一行一行
的读内容,有问题吗?





Learning, Just As Your Favourite Thing!

Maillist, See http://www.juliantec.info/mlist/mail-lists.html
JulBlog, See http://www.juliantec.info/julblog/summary.php
JulWiki, See http://www.juliantec.info/wiki/




Other related posts: