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

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

  1. #include <windows.h>
  2. #include <winnt.h>
  3. #include <stdio.h>
  4. int main(int argc, char* argv[])
  5. {
  6. HANDLE hConsoleWnd;
  7. hConsoleWnd = GetStdHandle(STD_OUTPUT_HANDLE);
  8. SetConsoleTextAttribute(hConsoleWnd,FOREGROUND_RED);
  9. printf("I am red now!\n");
  10. SetConsoleTextAttribute(hConsoleWnd,FOREGROUND_INTENSITY);
  11. printf("I am gray now!\n");
  12. return 0;
  13. }

VC printf输出彩色字体的更多相关文章

  1. python输出彩色字体

    Python终端如何输出彩色字体 实现过程:       终端的字符颜色是用转义序列控制的,是文本模式下的系统显示功能,和具体的语言无关.       转义序列是以ESC开头,即用\033来完成(ES ...

  2. Python终端如何输出彩色字体

    实现过程:       终端的字符颜色是用转义序列控制的,是文本模式下的系统显示功能,和具体的语言无关.       转义序列是以ESC开头,即用\033来完成(ESC的ASCII码用十进制表示是27 ...

  3. Python3使用Print输出彩色字体

    一.介绍 在一些开发程序中,有些输出消息需要突出显示,我们可以尝试着给他们换上更靓丽的颜色来突出显示. 二.实现过程 终端的字符颜色是用转义序列控制的,是文本模式下的系统显示功能,和具体的语言无关. ...

  4. Node.js中的console.log()输出彩色字体

    转自:https://www.jianshu.com/p/cca3e72c3ba7 console.log('\033[42;30m DONE \033[40;32m Compiled success ...

  5. C# 控制台应用程序中输出彩色字体

    using System; class Example { public static void Main() { // Get a string array with the names of Co ...

  6. console输出彩色字体

    console.log("%c%s","color: red; background: yellow; font-size: 24px;","警告!& ...

  7. [笔记]Go语言在Linux环境下输出彩色字符

    Go语言要打印彩色字符与Linux终端输出彩色字符类似,以黑色背景高亮绿色字体为例: fmt.Printf("\n %c[1;40;32m%s%c[0m\n\n", 0x1B, & ...

  8. qt中如果用qDebug输出彩色调试信息

    Linux:  在终端输出彩色信息有点类似于html的语法,即在要输出的文字前加上转义字符. 指令格式如下\033[*m 这里的*就是转义字符,例如我们要输出一段绿色的文字 qDebug(" ...

  9. qt中如何用qDebug输出彩色调试信息

    原文 http://fanzhichao.blog.hexun.com/22330640_d.html 在终端输出彩色信息有点类似于html的语法,即在要输出的文字前加上转义字符. 指令格式如下\03 ...

随机推荐

  1. DM8168 debug continue... ...

    1.boot   VFS: Unable to mount root fs via NFS, trying floppy.   VFS: Cannot open root device "n ...

  2. leetcode第三题Longest Substring Without Repeating Characters java

    Longest Substring Without Repeating Characters Given a string, find the length of the longest substr ...

  3. 关于Java(Hello World程序)

    详解 Hello World 应用程序 源码 class HelloWorldApp { public static void main(String[] args) { System.out.pri ...

  4. Hbase热点问题

    需求描述:扫描(查询)某个区间--->列用hbase多节点的资源,分布式扫描,加快速度==> 然后拼接到一起 如何打散数据 冠字号逆序,hash 并不一定数据连续就会造成热点,这个是由数据 ...

  5. 模拟键盘输入 : SendMessage, keybd_event, PostKeybdMessage

    转自模拟键盘输入 : SendMessage, keybd_event, PostKeybdMessage 目的 最近项目要求在Windows CE下模拟键盘输入,上网搜索了一下,发现有3个API可以 ...

  6. 算法练习之:Biorhythms

    Biorhythms Time Limit: 1000MS Memory Limit: 10000KB  Problem Description Some people believe that th ...

  7. Android 向系统添加一个联系人信息contact

    private void writeContacts() { Uri rawContacts = Uri.parse("content://com.android.contacts/raw_ ...

  8. LiBsvm用于多分类时训练模型参数含义

    The 'svmtrain' function returns a model which can be used for futureprediction.  It is a structure a ...

  9. 【HDOJ】1166 敌兵布阵

    线段树. #include <stdio.h> #define maxn 55555 ]; void PushUP(int rt) { sums[rt] = sums[rt<< ...

  10. javascript时间、随机数

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...