int txt_number;/* txt file's name*/
char txt_str[50];/*get txt file*/
char temp_path[10];
char filepath[50];
FILE *openfile=NULL;
char path_txt[]="D:\\txtdocument\\";
for(txt_number=1;txt_number<=20;txt_number++)
{
memset(txt_str,0,50);
memset(temp_path,0,10);
memset(filepath,0,50);
sprintf(temp_path,"%d.txt",txt_number);
strcpy(filepath,path_txt);
strcat(filepath,temp_path);
if( openfile=fopen(filepath,"r"))
{
fgets(txt_str,50,openfile);
printf("%s\n",txt_str);
/*
here 可以处理从文本里读进来的第一行字,如果是固定格式就要用分割符函数或者自己写分割函数,把字符分割后转换成数字存入数组
*/
fclose(openfile);
}
else
continue;
}