ok here I want to know how to make colorated output in C and C++...

For example: I want to print this string "zelena". The color must be green. Now how to get green output using printf() in C and cout << "zelena";

Recommended Answers

All 8 Replies

Member Avatar for iamthwee

Simple, use the SetConsoleTextAttribute() method from the Windows API

Simple, use the SetConsoleTextAttribute() method from the Windows API

Yeah, but i want to get colored output using printf() function...

Also I`m still complete n00b..

Member Avatar for iamthwee

You can still use it with printf.

Im realy confused now...could you write an example?

Im realy confused now...could you write an example?

Search the snippets section. You'll find code for that.

every chatacter occupies 2 Bytes in VDU memeory.
First is for its ascii value, while next for its color.
To change the color of the text, u need to change this Byte.

U must be able to right the required code for this now.
and one more thing, forget 'printf'

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.