R
R
Ruslan Kirichenko2020-05-24 10:41:47
C++ / C#
Ruslan Kirichenko, 2020-05-24 10:41:47

How to output colored console text in C++?

Hello! Guys who fumbles in C ++? Can you please tell me how to display colored text in C++?
I am writing a console program for practice, you can say a game, and I need if a person wins, then he shows green correct answers, if he loses, then red. I have already implemented and written the idea, but I can’t figure out how to make a color??

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir Korotenko, 2020-05-24
@firedragon

It all depends on the terminal.
https://stackoverflow.com/questions/33326039/c-ans...
And here is a description of the specifics for windows
https://superuser.com/questions/413073/windows-con...

T
Timur Pokrovsky, 2020-05-24
@Makaroshka007

https://ru.stackoverflow.com/questions/16431/%D0%A...
https://www.cyberforum.ru/cpp-beginners/thread5252...

P
pfemidi, 2020-05-24
@pfemidi

Ruslan Kirichenko , ANSI escape sequences, in this case specifically for changing colors . The truth is here:

it works on the windows platform, but under linux you need to use crutches here :)

exactly the opposite, in Linux it will work without problems, and under WIndows you will have to play a little tricky, for example, install an ANSI driver, some kind of ANSICON . I have had ANSICON in Windows Seven for eight years now without any problems, I installed it just for the sake of ESC sequences to change the color in the console so that git could communicate with colored letters.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question