How can I extract the error message from FILE *stderr and convert it into a string format?

39 views Asked by At

In my unit test case I want to check if the error message (written to STDERR FILENO) of a (failing) function is correct. For this I need to extract the error message from the FILE *stderr and convert it into a string format.

Does anyone know how to realize this?

1

There are 1 answers

0
Bjorn A. On

IMHO, functions should just return a status code, but never print error messages. That'd solve your unit test problem as well.