[comp.lang.c] Command line as a stream?

ram@lscvax.UUCP (Ric Messier) (04/26/88)

Is there a way to specify the command line as a stream in C? I realize
that you can get command line parms from the main but since the code I
am writing is an external procedure to Fortran code (specifically the
NCAR graphics package. anyone that has already implemented this package
and knows what procedure I am talking about would be able to help me
greatly), I need a way to do it outside of the main code.

Since I know input gets buffered, I am assuming that that buffer can be
opened by specifying it in a stream. Am I wrong in this assumption? Any
help would be greatly appreciated!! Thanks!

-- 
- Kilroy                ram@lscvax.UUCP                 *** Can't deal, &CRASH
'Just what cowpatch is Lyndonville, Vermont in anyway?'
Recursion - a procedure or function that calls itself
            SEE RECURSION

barmar@think.COM (Barry Margolin) (05/01/88)

In article <404@lscvax.UUCP> ram@lscvax.UUCP (Ric Messier) writes:
>Since I know input gets buffered, I am assuming that that buffer can be
>opened by specifying it in a stream. Am I wrong in this assumption? Any
>help would be greatly appreciated!! Thanks!

First of all, you can't be sure that your command was actually called
by the shell.  It might have been invoked by a program calling
system() or exec().

When it is called from the shell, the command line is buffered, but
unfortunately it is not anywhere accessible to the program.  It is
buffered in the shell's process, but the command is run in a separate
process.

The best thing for you to do would be to have a pair of global
variables, global_argc and global_argv, and have main() do

	global_argc = argc;
	global_argv = argv;

Then you can refer to these from anywhere in your program.

Barry Margolin
Thinking Machines Corp.

barmar@think.com
uunet!think!barmar