+ 1
How to color it in C++
I made a calculator with C++ but how do I color it, design it I mean there is css for web sites but in C++ how can I color it
4 Antworten
+ 1
there are some ways to do it. this approach is better than system(color f2). you can use any combination of red green and blue on the foreground (text) and the background. don't forget to include <window.h>. it only works in windows console.
example:
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleTextAttribute(hConsole, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
std::cout << "Hey there!" << std::endl;
source:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms682088(v=vs.85).aspx#_win32_character_attributes
- 1
You can use SDL or SFML
- 1
If you are on Linux then you can use escape sequences.
Search for it on Google. It is very easy.