$cc a.c
$./a.out < inpfilename
I want to print inpfilename on stdout. How do I do that ? Thanks for the help in advance...
Your operating system will supply your program with input from this file. This is transparent to your program, and as such you don't get to see the name of the file. In fact, under some circumstances you will be fed input which doesn't come from a file, such as this:
ls | ./a.out
What you're after is very system-specific. Probably a better solution is to pass the filename as a parameter. That way you get the filename, and you can open it to read the content.