0 کاربر و 3 مهمان درحال مشاهده موضوع.
#include <stdio.h>#include <iostream>#ifdef _WIN32#include <windows.h>#endif#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 7void textcolor(int attr, int fg, int bg);int main(){ textcolor(BRIGHT, RED, BLACK); std::cout << "In Color\n"; textcolor(RESET, WHITE, BLACK); return 0;}void textcolor(int attr, int fg, int bg){#ifdef _WIN32 system("color YOUR_COLOR_HERE");#endif#ifdef __linux__ 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);#endif}