更新时间:2023-02-04 23:40:25
字符字符串[SIZE]
freopen函数(的/ dev / null的,一,标准输出);
则setbuf(标准输出,字符串);
in C
i want to redirect the output of a process from stdout to write to a "shared memory segment" which can be thought of as a char array or a string with a pointer
i know that there is dup2 but it takes file discriptors as argument not a pointer to an array. is there any way to redirect it to a string?
char string[SIZE];
freopen("/dev/null", "a", stdout);
setbuf(stdout, string);