hi!

i want to print a colored 'A' using putchar, let's say green.
i am able to print * by doing just putchar('A');
but i don't know that how to print a colored 'A'.
i have also tried to write:

putchar('A',255);

and also

putchar('A',3);

but no success.

Member Avatar
embooglement

Doing things like that is generally operating system dependent, so you'll need to look at the documentation for your OS's API to see if/how it supports something like that.

This is an example.

#include <string>

void color(){

cout << "write a number" << endl;
string color;
cin >> color;


system( ("color "+color).c_str() );

}
Member Avatar
embooglement

This is an example.

#include <string>

void color(){

cout << "write a number" << endl;
string color;
cin >> color;


system( ("color "+color).c_str() );

}

That will work provided whatever OS sajid1 is using supports that; not all do. However, at least on windows, that does not write a character with a color. That sets the color scheme for the entire console, including any characters that have already been written, and those that will be written later.