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

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -