Home >Backend Development >C++ >How Can I Print Colored Text in a Linux Terminal?
Outputting Coloured Text to a Linux Terminal
Question: How can I display coloured text in a Linux terminal that supports this feature?
Answer: To output coloured characters, you need to utilize ANSI colour codes. However, it's crucial to note that not all terminals possess this capability. If colour sequences are not supported, the terminal will display garbage instead.
For instance:
cout << "3[1;31mbold red text3[0m\n";
In this example,
The above is the detailed content of How Can I Print Colored Text in a Linux Terminal?. For more information, please follow other related articles on the PHP Chinese website!