Windows DOS window Set Font color

Source: Internet
Author: User

2015-04-21 10:54:43

1#include <windows.h>2#include <iostream>3 using namespacestd;4 #defineColor_count 155 6 //void SetColor (unsigned short ForeColor = 3, unsigned short backgroundcolor = 0)7 voidSetColor (intcolor)8 {9     if(Color <0|| Color >= the)Ten         return; One  A     StaticWORD Wincolorfg[color_count] = -     { -         0,//BLACK theForeground_red,//RED -Foreground_green,//GREEN -foreground_red | Foreground_green,//BROWN -Foreground_blue,//BLUE +foreground_red | Foreground_blue,//MAGENTA -Foreground_green | Foreground_blue,//CYAN +foreground_red | Foreground_green | Foreground_blue,// White Aforeground_red | Foreground_green | Foreground_intensity,//YELLOW atforeground_red | Foreground_intensity,//Red_bold -Foreground_green | Foreground_intensity,//Green_bold -Foreground_blue | Foreground_intensity,//Blue_bold -foreground_red | Foreground_blue | Foreground_intensity,//Magenta_bold -Foreground_green | Foreground_blue | Foreground_intensity,//Cyan_bold -foreground_red | Foreground_green | Foreground_blue | Foreground_intensity//White_bold in     }; -HANDLE Hconsole =GetStdHandle (std_output_handle); to Setconsoletextattribute (Hconsole, Wincolorfg[color]); +     /*Setconsoletextattribute (hconsole, ForeColor | BackgroundColor);*/ - } the  * intMain () $ {Panax Notoginseng      for(inti =0; I < the; ++i) -     { the SetColor (i); +cout<<"Hello world!"<<Endl; A     } the     /*SetColor (); + cout<< "Hello world!" <<endl; - SetColor (foreground_red); $ cout<< "Hello world!" <<endl; $ cout<< "Hello world!" <<endl;*/ -System"Pause"); -     return 0; the}

Windows DOS window Set Font color

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.