$cc a.c
$./a.out < inpfilename
I want to print inpfilename on stdout. How do I do that ? Thanks for the help in advance...
Why do you want to do this? All your program a.out
is passed from the shell, is an open file descriptor, stdin.
The user might as well do this:
cat inpfilename | ./a.out
and now you have absolutely no filename to use (except /dev/stdin).
If a.out
needs to work with filenames, why not take the file as a command-line argument?