printf by default writes on stdout , if you want to write to a specific stream you should use fprintf which accepts a FILE* as the destination stream. Also it's "std" out because it's called "standard" output.
The simplest way you can do is: #include <stdlib. h> system("Color F3");
I have a program that log things to STDOUT
.
Those log entries have an associated "log level" (debug, warning, information, and so on) and I'd like to give the user the ability to color this output, depending on the log level.
What is the way of determining if STDOUT
is attached to a terminal that is-color capable ? And how can I output my text with colors then ?
I'm looking for a solution that involves only C or C++ calls. I guess curses
(or ncurses
) has something to ease this, but I'd like to avoid its use to keep my dependencies to a minimum.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With