I have been using dup
and freopen
to rerout stdout
to a file as below:
fflush(stdout);
fgetpos(stdout, &pos);
fd = dup(fileno(stdout));
freopen("stdout.out", "w", stdout);
What I would like to do would be rerout it to a char[]
, so that I can manipulate it. obviously this isn't very useful when writing with printf
, but when using libraries that write to stdout
, it would be helpful to get the output in the code so I can manipulate it, if necessary.