|[ < ]||[ > ]||[ << ]||[ Up ]||[ >> ]||[Top]||[Contents]||[Index]||[ ? ]|
#include <stdio.h> FILE *popen(const char *cmd, const char *mode);
This function executes the command or program specified by
and attaches either its input stream or its output stream
to the returned file. While the file is open, the calling program
can write to the program (if the program was open for writing)
or read the program's output (if the program was opened for reading).
When the program is done, or if you have no more input for it, pass
the file pointer to
pclose (see section pclose), which terminates
Since MS-DOS does not support multitasking, this function actually runs
the entire program when the program is opened for reading, and stores
the output in a temporary file.
pclose then removes that file.
Similarly, when you open a program for writing, a temp file holds the
pclose runs the entire program.
The mode is the same as for
fopen (see section fopen), except
that you are not allowed to open a pipe for both reading and writing. A
pipe can be open either for reading or for writing.
An open file which can be used to read the program's output or write to the program's input.
FILE *p = popen("dir", "r"); read_program(p); pclose(p);
|webmaster donations bookstore||delorie software privacy|
|Copyright © 2004 by DJ Delorie||Updated Apr 2004|