Results 1 to 2 of 2
Is it possible if I want to read userinput with fgets() that it comes from a file? Not into argv[]!...
- 10-24-2007 #1Just Joined!
- Join Date
- Apr 2005
- Posts
- 5
Userinput via file
Is it possible if I want to read userinput with fgets() that it comes from a file? Not into argv[]!
- 10-24-2007 #2
I'm not sure what you're asking.
If you're asking whether you can get input from an arbitrary file which is not named in argv[], then sure, put that arbitrary filename into the call to fopen().
But maybe you mean that you get the filename itself from a file. You can do that too.
Open the file that contains the filename, using fopen(). Read the filename using fgets(). Then fclose() the file containing the filename in question.
Open the file whose name you just read in the previous paragraph; use fopen() to do so. Read the data in that file with fgets(). When you're done, call fclose() for that file.
Or did you mean something else?


Reply With Quote