Jan 3, 2001 #1 bob323 MIS Jan 3, 2001 5 US I'm kind of new to C, and I want get a file address from the dos prompt and open it any ideas?
Jan 3, 2001 #2 rbobbitt Programmer Aug 17, 2000 566 US This is a pretty basic thing in C. If you take a look at any C book or even a web tutorial, this should be covered. I assume by "address" you mean a file name. I'm not sure if this will help, but here's a short example that opens and closes a file: /**** Untested (but if should be fine) ****/ #include <stdio.h> #include <stdlib.h> int main(int argc,char **argv) { FILE *fp; if (argc<2) { fprintf(stderr,"usage: %s <filename>\n",argv[0]); return EXIT_FAILURE; } fp=fopen(argv[1],"r" if (NULL!=fp) { /* Do stuff with file */ fclose(fp); } else { fprintf(stderr,"Failed to open file %s\n",argv[1]); return EXIT_FAILURE; } return 0; } If this isn't what you want, please clarify with another post. Russ bobbitts@hotmail.com http://home.earthlink.net/~bobbitts Upvote 0 Downvote
This is a pretty basic thing in C. If you take a look at any C book or even a web tutorial, this should be covered. I assume by "address" you mean a file name. I'm not sure if this will help, but here's a short example that opens and closes a file: /**** Untested (but if should be fine) ****/ #include <stdio.h> #include <stdlib.h> int main(int argc,char **argv) { FILE *fp; if (argc<2) { fprintf(stderr,"usage: %s <filename>\n",argv[0]); return EXIT_FAILURE; } fp=fopen(argv[1],"r" if (NULL!=fp) { /* Do stuff with file */ fclose(fp); } else { fprintf(stderr,"Failed to open file %s\n",argv[1]); return EXIT_FAILURE; } return 0; } If this isn't what you want, please clarify with another post. Russ bobbitts@hotmail.com http://home.earthlink.net/~bobbitts