Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Newbie question
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 ?

How is it different from  - a.out  foo.txt

Thanks.

Report this thread to moderator Post Follow-up to this message
Old Post
K.M Jr
09-29-04 10:00 AM


Re: Newbie question
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 ***

Report this thread to moderator Post Follow-up to this message
Old Post
Barry Margolin
09-30-04 01:07 AM


Re: Newbie question
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
The shell opens foo.txt as stdin for you.

> 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 ?
>
> How is it different from  - a.out  foo.txt
The string foo.txt will be in argv[1], and you have to
open it if desired.

Report this thread to moderator Post Follow-up to this message
Old Post
Nils O. Selåsdal
09-30-04 01:07 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Unix Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:39 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.