#include "stdio.h" /*the include for stdio.h must be before main and must have quotes*/ main(argcnt,argpt) int argcnt;/*standard argument count*/ char * argpt[];/* pointers to each argument. arguments are space delimited*/ { FILE *fpi, *fpo, *fopen();/* file declaration required for fopen*/ char * outnam;/* output file name*/ int c;/* character holder*/ long count;/* count of number of lines on the fsa file*/ fpi = fopen(argpt[1],"r") ;/* open the input file*/ if (fpi==NULL) error("file %s open failed",argpt[1]); if(argcnt==2){/* if only the input file was specified*/ printf("NUMBER OF CHARACTERS PER RECORD:"); scanf("%s",outnam);/*conform to old fortran program questions*/ printf("OUTPUT FILE NAME:");/* notice number of chars not used*/ scanf("%s",outnam);/*get the output file name*/ fpo=fopen(outnam,"w");}/*open the output file*/ if(fpo==NULL) error("file %s open failed",outnam); if(argcnt>=3)/*both input and output files specified as arguments?*/ fpo = fopen(argpt[2],"w");/*open output file from name in second place*/ if (fpo==NULL) error("output file open failed");/*AS endless loop for ...error("file %s open failed",argpt[2])*/ c=getc(fpi);/*first character in fsa file is a line feed so skip it*/ count=0;/*initialize counter*/ while((c=getc(fpi))!=EOF)/*keep going until end of file*/ if(c=='\n')/*if this is the end of a line*/ ++count;/* count it*/ fprintf(fpo,"LEN_ ");/*put length out in APL format*/ fprintf(fpo,"%ld\n",count);/*%D didn't work*/ }/*files seem to close automatically*/