Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- colors_in_c_v1.c
- COLOR [attr]
- attr Specifies color attribute of console output
- Color attributes are specified by TWO hex digits -- the first
- corresponds to the background; the second the foreground. Each digit
- can be any of the following values:
- background foreground
- 0 = Black 8 = Gray
- 1 = Blue 9 = Light Blue
- 2 = Green A = Light Green
- 3 = Aqua B = Light Aqua
- 4 = Red C = Light Red
- 5 = Purple D = Light Purple
- 6 = Yellow E = Light Yellow
- 7 = White F = Bright White
- If no argument is given, this command restores the color to what it was
- when CMD.EXE started. This value either comes from the current console
- window, the /T command line switch or from the DefaultColor registry
- value.
- The COLOR command sets ERRORLEVEL to 1 if an attempt is made to execute
- the COLOR command with a foreground and background color that are the
- same.
- Example: "COLOR fc" produces light red on bright white
- system("COLOR FC");
- foreground
- Example: for blue color of letters write
- system("COLOR 1");
- */
- #include <stdio.h>
- #include <stdlib.h>
- int main (void)
- {
- int background, foreground;
- char color[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
- 'A', 'B', 'C', 'D', 'E', 'F'};
- char command[10];
- for(background=0; background<16; background++)
- for(foreground=0; foreground<16; foreground++)
- {
- sprintf(command,"COLOR %c%c",color[background],color[foreground]);
- system(command);
- printf ("\n %s ", command);
- printf ("\n");
- _getch();
- }
- system("COLOR 07"); // reset colors
- return 0;
- }
Advertisement
RAW Paste Data
Copied
Advertisement