#include #define MAXFILES 10 #define STRSZ 256 #define SEPCHR ';' main(int argc, char **argv) { FILE * inputfile[MAXFILES]; char s[STRSZ]; int nfiles=argc; int done = 0; if( --nfiles == 0 ) { fprintf(stderr,"Uso: %s file [file...]\n",argv[0]); exit(-2); } while(--argc>0) { if ((inputfile[argc-1]=fopen(argv[argc],"r"))==NULL) { perror("open"); exit(-1); } } while( !done ) { for( argc = 0; argc < nfiles ; ) { done= (NULL==fgets(s,STRSZ,inputfile[argc])); if (done) break; s[strlen(s)-1]=0x00; printf( "%s%c", s,++argc==nfiles?'\n':SEPCHR); } } for( argc = 0; argc < nfiles ; argc++) fclose( inputfile[argc] ); }