09-29-04 08:09 AM
In article <8228b1d2.0409290041.3a4b88c6@posting.google.com>,
opwv_pspl_test2@yahoo.com (K.M Jr) wrote:
> Hi group,
>
> I got a pretty simple question -
>
> Say I have a C program (executable as a.out)
> What does this do - a.out < foo.txt
>
> I believe I am piping foo.txt to a.out. But how is it available to
> program i.e. how do I access foo.txt in the program ?
No, there's no pipe -- a pipe is a connection between two processes.
The shell opens foo.txt and connects it to the process's standard input.
You access it by reading from stdin.
>
> How is it different from - a.out foo.txt
In this case, the program has to open the file itself.
By convention, most Unix programs that accept filename arguments will
automatically read from standard input if they don't get any filenames.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
[ Post a follow-up to this message ]
|