because these forums are mainly used for help, I wanted to enrich the environment with a little program I am working on, I have one that has more code but this is the program before I added to it. A nice color interface!
the original source was found on some website, I will post it as soon as I find it, the true author of textcolor() should get credit.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() { char ans; system("clear"); printf("\t\t\t\t"); textcolor(BRIGHT,BLUE,BLACK); printf("Welcome!"); textcolor(RESET,WHITE,BLACK); printf("\nTest!\n"); // Menu plus more functions here printf("Do you want to continue? [y/n]: "); scanf("%c",&ans); printf("%c\n",ans); if(ans == 'y' ) { printf("good!"); //more code here } else { printf("bad!"); // more code here } printf("\n"); 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); } // more functions here //basically I commented out the stuff I had in the bigger program



LinkBack URL
About LinkBacks


