Matt
Matt

Reputation: 427

Can I easily change the colour of text output to the Windows Console from a C Program

I want to make some printf's to the windows console from my C program but want to make some of them different colours.

Anyone know if this can be done easily?

EDIT: Windows XP is my OS

Upvotes: 0

Views: 705

Answers (2)

Michael Burr
Michael Burr

Reputation: 340198

SetConsoleTextAttribute() will let you set the color of subsequent text output.

You'll probably want to look at the complete set of Win32 console APIs to be able to get/set/restore and otherwise manipulate the console.

Upvotes: 1

Ruel
Ruel

Reputation: 15780

That's not possible in CMD (correct me if I'm wrong). You can only change the foreground and background color of CMD as a whole. Not by line, or word.

For changing its foreground and background colors please refer to the color command:

color /?

Upvotes: 0

Related Questions