回复 9楼 wube
你這些文檔,記錄結構都不一樣,要怎麽處理?
授人以渔,不授人以鱼。
void MergeCSV(int fl,char *Tmp, char *TmpFileNameStr1,int TC) { FILE *stream2,*stream3[300]; //这个地方300怎么改成动态声明? int i=0,j=0; char TempString[Max_Size]={0},temp[Max_Size]={0}; stream2 = fopen(TmpFileNameStr1, "a+" ); for (j=0;j<fl;j++) { sprintf(TempString,"%s%04d.csv",Tmp,j); stream3[j] = fopen( TempString, "r" ); memset(TempString,0,sizeof(TempString)); } for (i=0;i<(TC+6);i++) { for (j=0;j<fl;j++) { if (fgets(temp, Max_Size, stream3[j])!=NULL) { int ii=strlen(temp); temp[ii-1]='\0'; fprintf(stream2,"%s",temp); } memset(temp,0,sizeof(temp)); fflush(stream2); } fprintf(stream2,"\n"); } for (j=0;j<fl;j++) fclose(stream3[j]); fclose(stream2); }