in reply to using colors with print()
#define RESET 0 #define BRIGHT 1 #define DIM 2 #define UNDERLINE 3 #define BLINK 4 #define REVERSE 7 #define HIDDEN 8 #define BLACK 0 #define RED 1 #define GREEN 2 #define YELLOW 3 #define BLUE 4 #define MAGENTA 5 #define CYAN 6 #define WHITE 7 void textcolor(int attr, int fg, int bg); int main() { textcolor(RESET, RED, BLACK); printf("In color"); textcolor(RESET, WHITE, BLACK); return 0; } void textcolor(int attr, int fg, int bg) { char command[13]; /* Command is the control command to the terminal */ sprintf(command, "%c[%d;%d;%dm", 0x1B, attr, fg + 30, bg + 40); printf("%s", command); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: using colors with print()
by thunders (Priest) on Jun 19, 2004 at 22:08 UTC | |
by pbeckingham (Parson) on Jun 19, 2004 at 23:56 UTC | |
by tachyon (Chancellor) on Jun 20, 2004 at 09:30 UTC | |
by pbeckingham (Parson) on Jun 20, 2004 at 15:50 UTC |