operating system - how can we read the content of stdin stdout stderr in c? -
#include<stdio.h> #include<unistd.h> #include<fcntl.h> void main() { int stdout_bk,stdin_bk,stderr_bk; char x[100],y[100],z[100]; stdout_bk=dup(fileno(stdout)); stdin_bk=dup(fileno(stdin)); stderr_bk=dup(fileno(stderr)); read(stdin_bk,x,100); read(stdout_bk,y,100); read(stderr_bk,z,100); printf("\n%s",x); printf("\n%s",y); printf("\n%s",z); }
i have tried but, did not proper answer. how buffer works while running c program?
Comments
Post a Comment