user-0 提问: 从txt依次读取路径，根据路径读取相应文件的第二行的特定数据，循环1812个路径，500多个的时候，debug assertion failed

回复:
user: user-1
content: 虎头蛇尾是俗人的习惯， 有始有终是君子的操守。

user: user-2
content: 你里面的文件操作中，文件打开用过后都不关闭吗？

user: user-0
content: http://pan.baidu.com/s/1i366TW5 nnlw 链接：http://pan.baidu.com/s/1ctbvo 密码：sk5c 相关txt文件

user: user-1
content: 小心驶得万年船！ #include <stdio.h> #include <string.h> #include <stdlib.h> #define  MAX  10000 char array[MAX][1024]; int i; void ReadFaceNumber(char *filename) {     FILE  *fp1;     int   face_number,vertex_number,edge_number;     char  file_type[64];     char  line[128];     int len;      fp1=fopen(filename,"r");     if (NULL==fp1) {         printf("Can not open %d file:[%s]!\n",i,filename);         return;     }     if (NULL==fgets(line,128,fp1)) {         printf("%d file:[%s] no 1 line!\n",i,filename);         fclose(fp1);         return;     }     len=strlen(line);     if ('\n'==line[len-1]) line[len-1]='\0';     if (1!=sscanf(line,"%63s",file_type)) {         printf("%d file:[%s] 1 line[%s] can not read file_type!\n",i,filename,line);         fclose(fp1);         return;     }     if (NULL==fgets(line,128,fp1)) {         printf("%d file:[%s] no 2 line!\n",i,filename);         fclose(fp1);         return;     }     len=strlen(line);     if ('\n'==line[len-1]) line[len-1]='\0';     if (3!=sscanf(line,"%d%d%d",&vertex_number,&face_number,&edge_number)) {         printf("%d file:[%s] 2 line[%s] can not read 3 number!\n",i,filename,line);         fclose(fp1);         return;     }     printf("%d file:[%s] 2 line[%s] face_number:%d\n",i,filename,face_number);     fclose(fp1); } int main(void) {     FILE  *fp;     int   len;     char  buf[1024];     fp=fopen("E:\\ee.txt","r");     if (NULL==fp) {         printf("Can not open file E:\\ee.txt!\n");         return 1;     }     i=0;     while (1) {         if (NULL==fgets(buf,1024,fp)) break;         len=strlen(buf);         if ('\n'==buf[len-1]) buf[len-1]='\0';         strcpy(array[i],buf);         printf("%s\n",array[i]);         ReadFaceNumber(buf);         i++;         if (i>=MAX) {             printf("Ignore >%d lines\n",MAX);             break;         }     }     fclose(fp);     return 0; }

user: user-0
content: 谢谢  大家问题已经发现了    原来是我的txt文本中一个路径  没有对应的OFF   所以打开一个不存在的文件自然就出错了 不过 还是请大家看看我的这段代码   它的格式 有哪些是不必要的请大家看看

user: user-0
content: 刚才   关闭了文件 已经能循环到760多了 但还是报同样的错误 #include <stdio.h> #include <string.h> #include <stdlib.h> #define  MAX  10000 char *array[MAX]; void ReadFaceNumber(char *filename);  int main(void) { 	FILE  *fp; 	int   len=0; 	int   i=0; 	char  buf[1024]; 	fp=fopen("E:\\ee.txt","r"); 	while(fgets(buf,1024,fp)!=NULL) 	{ 		len=strlen(buf); 		buf[len-1]='\0'; 		array[i]=(char*)malloc(len+1); 		strcpy(array[i],buf); 		printf("%s\n",array[i]); 		ReadFaceNumber(buf); 	} 	fclose(fp);  	i--; 	while(i>=0&&array[i]) 	{ 		free(array[i--]); 	} }   void ReadFaceNumber(char *filename) { 	FILE  *fp1; 	int   face_number,vertex_number,edge_number; 	char  file_type[64]; 	char  line[128]; 	 	fp1=fopen(filename,"r"); 	fgets(line,1024,fp1); 	sscanf(line,"%s",file_type); 	fgets(line,1024,fp1); 	sscanf(line,"%d %d %d",&vertex_number,&face_number,&edge_number);  	printf("face_number:%d\n",face_number); 	fclose(fp1);  }

user: user-0
content: 恩       谢谢你们的提醒