I have tried that before. In the console window you only have one colour for the foreground and background. In older versions of DOS you could use escape sequence to change the colour. If it is still available I have not found the files necessary to use the escape sequences.
I hate it when people say you can't... Of course you can that's why we program...
Btw, 0 is black but you can't see black on black so no reason to display it here.
@SamuelAdams
Maybe it is better if you give him a Color enum so that he can just instantly use it without worrying about the code itself or how to use the code.
With that code he can see all the colors and fill in the etc himself.
I'm not sure I'd recommend that code for a beginner doing homework but I was not happy Yanson said you can't change colors. I'm sure there are multiple ways.
CRAFSHIN, copy and paste the SetColor function into your project and call it before you want to change the colour of the text. Like this if you wanted your text to be green.
I'm sorry, I knew it was too complex but shows it is possible. Yes there are many ways, just google to find a few.
The code I provided is a function called SetColor. The part in main prints out the colors 1-15, 0 is black so you wouldn't be able to see it on a black screen.
The colors are
Name | Value
Black | 0
Blue | 1
Green | 2
Cyan | 3
Red | 4
Magenta | 5
Brown | 6
Light Gray | 7
Dark Gray | 8
Light Blue | 9
Light Green | 10
Light Cyan | 11
Light Red | 12
Light Magenta| 13
Yellow | 14
White | 15
Thank you for the code, but I just don't understand the code, I mean I don't understand the meaning of those lines in that code, because I just started programming and I don't know how to use that code in my project.
Would it be something like this? I don't know...
// Color Picker
#include <iostream>
#include <windows.h>
using namespace std;
I agree, a lot of bad code is written every day. But if he stays in programming long enough he's going to see good and bad examples, and needs exposure to both so he can learn the difference before he actually codes something important.