我想写一些类似的内容:
cout << "this text is not colorized\n";
setForeground(Color::Red);
cout << "this text shows as red\n";
setForeground(Color::Blue);
cout << "this text shows as blue\n";
我有一个在Windows 7下运行的C++控制台程序。我已经了解到可以从cmd.exe的设置或通过调用system()来更改全局前景色和背景色,但是否有任何方法可以在字符级别上编码进程序来更改这些内容呢?起初我想到了" ANSI序列",但在Windows平台上似乎已经失传了。