Things don't have to be black and white all the time. Use a Windows API call to add some color to your text output.
Add a little Color to your Console Text
// color your text in Windows console mode
// colors are 0=black 1=blue 2=green and so on to 15=white
// colorattribute = foreground + background * 16
// to get red text on yellow use 4 + 14*16 = 228
// light red on yellow would be 12 + 14*16 = 236
// a Dev-C++ tested console application by vegaseat 07nov2004
#include <iostream>
#include <windows.h> // WinApi header
using namespace std; // std::cout, std::cin
int main()
{
HANDLE hConsole;
int k;
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
// you can loop k higher to see more color choices
for(k = 1; k < 255; k++)
{
// pick the colorattribute k you want
SetConsoleTextAttribute(hConsole, k);
cout << k << " I want to be nice today!" << endl;
}
cin.get(); // wait
return 0;
}
venomlash 55 Junior Poster
Akilah712 0 Newbie Poster
mistercow.pnoy 0 Newbie Poster
dombit 0 Newbie Poster
setherith 0 Newbie Poster
jamesysco 0 Newbie Poster
pwnedu46 0 Newbie Poster
shirish7151 -4 Newbie Poster
WaltP commented: Worthless in today's world -4
Philip_19 commented: it doesn't work in todays world, but cool legacy code +0
Philip_19 27 Newbie Poster
Reverend Jim commented: atrocious code -3
rproffitt commented: Did ChatGPT write this? No, I think it could do better. -4
Dani commented: Thank you for joining and contributing, I'm sorry for the rude comments you received +34
Reverend Jim 4,968 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
Dani 4,329 The Queen of DaniWeb Administrator Featured Poster Premium Member
Reverend Jim 4,968 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
Dani 4,329 The Queen of DaniWeb Administrator Featured Poster Premium Member
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.