Oops, my bad. So you replace the cout with printf.
Maybe this will help you out just a bit more :
Sorry, I didnt notice that you are using C language & you also replaced the cout with printf it seems. Hope this helps you out more.
Code:
#include <stdio.h>
#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(BRIGHT, RED, BLACK);
printf("In color\n");
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);
}
Bookmarks