Capture result from a function in C (cmd1 | cmd2) -


let cmd1 print on stdout. how can capture cmd1 in c such cmd1 | cmd2 works.

i.e

cmd1{     fprintf(stdout, "hello");     }  cmd2 : should take "hello" , print "hel". 

to enable pipeline operation, cmd2 should read stdin.

for example, since fgets() reads stdin, can like:

#include <stdio.h>  int main() {     char buf[1024];     while (fgets(buf, sizeof(buf), stdin)) {         printf("%.*s\n", 3, buf);     }     return 0; } 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -