How do i change the font color in my C++ programs??? For linux? For Windows??
How do i change the font color in my C++ programs??? For linux? For Windows??
Do a search on the board for something like 'changing color'. Someone posted a really handy color changer function a while back. I can't remember who it was, but you could do a search for their name if someone else remembers who...
Blue
Try running this. It shows all of the colors and the code is easy to understand.
Code:#include <windows.h> #include <iostream.h> #include <stdio.h> void gotoxy(int x, int y) { COORD coord; coord.X = x; coord.Y = y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord); } void color(int color) { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),color); } void main () { int i = 0; for (int x = 0; x <= 79; x+=3) { for (int y = 0; y <= 49; y+=3) { color(i); gotoxy(x,y); printf("%1d",i); i++; if (i > 255) break; } if (i > 255) break; } }
>void main ()
tim, I know you didn't use void main. My eyes must be playing tricks on me due to sleep deprivation
-Prelude
My best code is written with the delete key.
I made that program late at night. I didn't feel like spending the extra 3 seconds writing return 0. I'm sorry. Here's the real version:
Code:#include <windows.h> #include <iostream.h> #include <stdio.h> void gotoxy(int x, int y) { COORD coord; coord.X = x; coord.Y = y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_H ANDLE), coord); } void color(int color) { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HA NDLE),color); } int main (void) { int i = 0; for (int x = 0; x <= 79; x+=3) { for (int y = 0; y <= 49; y+=3) { color(i); gotoxy(x,y); printf("%1d",i); i++; if (i > 255) break; } if (i > 255) break; } return (0); }
Maybe I should change my name to "Goddess of Nitpicking".
-Prelude
My best code is written with the delete key.
Or maybe perfectionist prick!!!!!
Hehe just kidding.