Answer the question
In order to leave comments, you need to log in
What is the best way to display colored text in the console?
Interested in a convenient way in terms of design to display part of the text in color using esc sequences.
Now I'm using something like this:
#include <stdio.h>
#define TATR_OFF "\033[0m"
#define TATR_INF "[\033[1;34minf\033[0m] "
#define TATR_WRN "[\033[1;33mwrn\033[0m] "
#define TATR_ERR "[\033[1;31merr\033[0m] "
#define MSG_INF(msg) (TATR_INF msg)
#define MSG_WRN(msg) (TATR_WRN msg)
#define MSG_ERR(msg) (TATR_ERR msg)
int main() {
puts(MSG_INF("info text"));
puts(MSG_WRN("warning text"));
puts(MSG_ERR("error text"));
return 0;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question