Get file name from command line and open the file
#include <stdio.h> #include <stdlib.h> int main(void) { FILE *fp; char fname[128]; printf("Enter filename: "); gets(fname); if((fp=fopen(fname, "r"))==NULL) { printf("Cannot open file.\n"); exit(1); } fclose(fp); return 0; }