zoukankan      html  css  js  c++  java
  • VC printf输出彩色字体

     

    在VC下使用SetConsoleTextAttribute()函数可以改变当前控制台的前景色和背景色,从而达到输出彩色字体的效果。

    使用的方法也很简单,具体代码如下:

    [cpp] view plaincopy
     
    1. #include <windows.h>  
    2. #include <winnt.h>  
    3. #include <stdio.h>  
    4.   
    5. int main(int argc, char* argv[])  
    6. {  
    7.     HANDLE hConsoleWnd;  
    8.     hConsoleWnd = GetStdHandle(STD_OUTPUT_HANDLE);  
    9.     SetConsoleTextAttribute(hConsoleWnd,FOREGROUND_RED);  
    10.     printf("I am red now! ");  
    11.     SetConsoleTextAttribute(hConsoleWnd,FOREGROUND_INTENSITY);  
    12.     printf("I am gray now! ");  
    13.     return 0;  
    14. }  
  • 相关阅读:
    CSS中的单位简介
    grid-layout
    position
    form
    objects
    个人介绍
    第十二周作业:
    第十一周作业
    第十周web作业
    第九周作业
  • 原文地址:https://www.cnblogs.com/lvdongjie/p/4835000.html
Copyright © 2011-2022 走看看