IPC with pipes, demo of 'popen'

#include <stdio.h>

#include <unistd.h>



int main()

{

        FILE* stream = popen ("sort", "w");

        fprintf (stream, "This is a test.\n" );

        fprintf (stream, "Hello, world.\n");

        fprintf (stream, "My dog has fleas.\n");

        fprintf (stream, "This program is great.\n");

        fprintf (stream, "One fish, two fish.\n");

        return pclose (stream);

}

 

你可能感兴趣的:(demo)