| 1 |
/*********************************************************************** |
| 2 |
* Code listing from "Advanced Linux Programming," by CodeSourcery LLC * |
| 3 |
* Copyright (C) 2001 by New Riders Publishing * |
| 4 |
* See COPYRIGHT for license information. * |
| 5 |
***********************************************************************/ |
| 6 |
|
| 7 |
#include <stdio.h> |
| 8 |
#include <unistd.h> |
| 9 |
|
| 10 |
int main () |
| 11 |
{ |
| 12 |
FILE* stream = popen ("sort", "w"); |
| 13 |
fprintf (stream, "This is a test.\n"); |
| 14 |
fprintf (stream, "Hello, world.\n"); |
| 15 |
fprintf (stream, "My dog has fleas.\n"); |
| 16 |
fprintf (stream, "This program is great.\n"); |
| 17 |
fprintf (stream, "One fish, two fish.\n"); |
| 18 |
return pclose (stream); |
| 19 |
} |