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. }  
  • 相关阅读:
    HDU 6043
    HDU 6033
    HDU 6041
    HDU 6050
    HDU 6053
    HDU 6055
    HDU 6045
    HDU 6044
    HDU 6040
    ZUFE 1035 字符宽度编码(字符串)
  • 原文地址:https://www.cnblogs.com/lvdongjie/p/4835000.html
Copyright © 2011-2022 走看看