/* MODNAME.C - reads in the name from a .MOD file and prints it to stdout written by Tom Sorensen gt0040a@prism.gatech.edu */ #include main(int argv, char *argc[]) { char modname[21]; FILE *modfile; int i; if (argv<1) { fprintf(stderr," Correct usage is:\n"); fprintf(stderr,"MODFILE modname\n"); fprintf(stderr,"where modname is the the name of the .MOD file to\n"); fprintf(stderr,"be read, including the extension.\n"); exit(1); } if ((modfile = fopen(argc[1],"r")) == NULL) { fprintf(stderr,"Error- could not read %s.\n",argc[1]); fprintf(stderr,"Make sure file exists.\n"); exit(2); } for (i=0;i<20;i++) { modname[i]=fgetc(modfile); if (!(feof(modfile))) { fprintf(stderr,"Error- could not read first 20 bytes of %s\n", argc[1]); fprintf(stderr,"Make sure the file is a valid .MOD file.\n"); exit(3); } } fprintf(stdout,"%-15s : %s\n",argc[1],modname); return(0); }