Home >Backend Development >C++ >How Can I Output Colored Text to a Linux Terminal?

How Can I Output Colored Text to a Linux Terminal?

DDD
DDDOriginal
2024-12-13 01:10:13597browse

How Can I Output Colored Text to a Linux Terminal?

Outputting Coloured Text to Linux Terminals

Ansi colour codes can be used to print coloured text to terminals that support them. If the terminal does not support these codes, they will appear as unintended characters.

ANSI Colour Code Syntax

Example code to print bold red text:

cout << "3[1;31mbold red text3[0m\n";

Here,

The above is the detailed content of How Can I Output Colored Text to a Linux Terminal?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn