I was requested to write a program the basically parses the file given to it, with redirecting the stdin, like this:
myProg param1 param2 param3 < theFileToParse
I’m trying to use the fopen function in order to open the given file, but i don’t understand what should i give it in the ‘const char * filename’ argument.
You don’t need to open the file. Your program has a special value called
stdinwhich contains a handle to the process’s standard input stream. You can use this just as you would a file handle, for example:or: