From 28f540f45bbacd939bfd07f213bcad2bf730b1bf Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 18 Feb 1995 01:27:10 +0000 Subject: initial import --- manual/examples/popen.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 manual/examples/popen.c (limited to 'manual/examples/popen.c') diff --git a/manual/examples/popen.c b/manual/examples/popen.c new file mode 100644 index 0000000000..16ae32fa16 --- /dev/null +++ b/manual/examples/popen.c @@ -0,0 +1,33 @@ +#include +#include + +void +write_data (FILE * stream) +{ + int i; + for (i = 0; i < 100; i++) + fprintf (stream, "%d\n", i); + if (ferror (stream)) + { + fprintf (stderr, "Output to stream failed.\n"); + exit (EXIT_FAILURE); + } +} + +/*@group*/ +int +main (void) +{ + FILE *output; + + output = popen ("more", "w"); + if (!output) + { + fprintf (stderr, "Could not run more.\n"); + return EXIT_FAILURE; + } + write_data (output); + pclose (output); + return EXIT_SUCCESS; +} +/*@end group*/ -- cgit v1.2.3