Colorizing text in the console with C++

后端 未结 12 2619
礼貌的吻别
礼貌的吻别 2020-11-27 10:04

How can I write colored text to the console with C++? That is, how can I write different text with different colors?

12条回答
  •  感动是毒
    2020-11-27 11:00

    Standard C++ has no notion of 'colors'. So what you are asking depends on the operating system.

    For Windows, you can check out the SetConsoleTextAttribute function.

    On *nix, you have to use the ANSI escape sequences.

提交回复
热议问题