【发布时间】:2011-11-16 22:00:21
【问题描述】:
我读到了 ANSI-C 转义码 here。尝试在 C/C++ printf/cout 中使用它来着色输出到 consolde 但没有成功的文本。
代码:
#include <iostream>
#include <cstdio>
int main()
{
int a=3, b=5;
int &ref = a;
ref = b;
//cout << "\155\32\m" << a << b <<'\n'; //here it prints m→m 5, no colored text
printf("\155\32\m %d",a); //here to it prints same - m→m 5,
getchar();
}
如何使用这些转义码将彩色文本输出到控制台?
我错过了什么吗?
编辑:在一些 C++ 代码中我看到了对该函数的调用
textcolor(10);
但它会在 g++ 和 Visual Studio 中产生编译错误。哪个编译器有这个功能?有详细信息吗?
【问题讨论】: