码迷,mamicode.com
首页 > 其他好文 > 详细

vc 改变控制台字符颜色

时间:2015-06-08 21:34:49      阅读:99      评论:0      收藏:0      [点我收藏+]

标签:

#include <Windows.h>
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
    HANDLE hOut;

    hOut = GetStdHandle(STD_OUTPUT_HANDLE);

    SetConsoleTextAttribute(hOut,
        FOREGROUND_RED | 
        FOREGROUND_GREEN);
    cout << "This text is yellow." << endl;

    SetConsoleTextAttribute(hOut,
        FOREGROUND_GREEN | 
        FOREGROUND_BLUE);
    cout << "This text is cyan." << endl;

    SetConsoleTextAttribute(hOut,
        FOREGROUND_BLUE | 
        FOREGROUND_RED);
    cout << "This text is magenta." << endl;

    SetConsoleTextAttribute(hOut,
        FOREGROUND_RED | 
        FOREGROUND_GREEN | 
        FOREGROUND_BLUE);
    cout << "This text is white." << endl;

    return 0;
}

技术分享

vc 改变控制台字符颜色

标签:

原文地址:http://www.cnblogs.com/killbit/p/4561836.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!