#include #include #define MAX 250 int main(int argc, char *argv[]) { char buff[MAX]; char infile[80]; char outfile[80]; char name[21]; FILE *infp, *outfp ; if (argc < 2){ printf("入力ファイル名="); scanf("%s",infile); } else{ sprintf(infile,"%s", argv[1]); } if((infp=fopen(infile,"rt"))==NULL) { printf("%s file not open\n",infile); return(1); } while(fgets(buff,MAX,infp)!=NULL) { printf("%.20s に対する出力ファイル名=",buff); sscanf(buff+12,"%s",&name); /* copy design strings */ name[strlen(name)-1]='\0'; /* Cut last char. */ sprintf(outfile,"%s.elm",name); /* Make file name (xxx.elm) */ printf("%s\n",outfile); if((outfp=fopen(outfile,"wt"))==NULL) { printf("%s file not open\n"); return(1); } fputs(buff,outfp); fclose(outfp); } fclose(infp); return(0); }