Change Font Colour and Size

Can someone please tell me a method to change the font color and the size in c++.
I checked this link about it. But the explanation is not enough.

http://www.cplusplus.com/forum/beginner/3662/ //this gives an error ---> 'dosHandleOut' : undeclared identifier

http://msdn.microsoft.com/en-us/library/ms682088%28v=vs.85%29.aspx#_win32_character_attributes

Please i kindly request people who knows a lot about this could reply. It will be very helpful for all the beginners.
Thank you
Last edited on
Firstly, this is not "how to change text color in C++" but "how to change text color in windows console".
Secondly, could it be that you simply didn't declare a dosHandleOut? OP in that thread wrote a good snippet of code (if you replace the # with an appropriate constant).
You may shorten the code to SetConsoleTextAttribute( GetStdHandle(STD_OUTPUT_HANDLE), 0x0A);. This should be light green, if I remember correctly.
And you can't change text size, I think.
Last edited on
ok thanks i got the idea. But i still cant understand how to change the text color of a text. Did u mean we can't change the text color in windows 32 console apps?
BTW thank you so much for your reply.
What's you code?
1
2
3
cout << "This is normal ";
SetConsoleTextAttribute( GetStdHandle(STD_OUTPUT_HANDLE), 0x0A);
cout << "and this is green";
should work..
Topic archived. No new replies allowed.