Use the C language to output color-coded text on the Win console.
After learning the C language for so long, I have been stuck at the level of compiling the "console" program. However, black windows and white texts are boring. However, as a hobbyist, I don't have much time and energy to learn how to write window programs, nor do I have to use C to call a bunch of APIs to write them. After all, "console programs" can also be colorful.
If you don't talk much about it, go directly to the Code:
# Include <conio. h> # include <stdio. h> # include <windows. h> int main (int argc, char * argv []) {HANDLE hOut; hOut = GetStdHandle (STD_OUTPUT_HANDLE); int I; for (I = 1; I <255; I ++) {SetConsoleTextAttribute (hOut, I); printf ("% 3d \ t", I) ;}printf ("\ n"); SetConsoleTextAttribute (hOut, 0x0007); printf ("demo ended"); getch (); return 0 ;}
For me who are not good at English, I remember the functions, commands, and APIs. In fact, I typed a letter and a letter on the keyboard ......