I'm assuming you want to do this in Windows? Check the gametutorials page
http://www.gametutorials.com/Tutorials/c++/Cpp_Pg4.htm.
But here's the function on that page. I haven't tried it, but it'll probably work.
Code:
void DrawColorString(string szText, int X, int Y, WORD color)
{
HANDLE OutputH;
COORD position = {X, Y};
OutputH = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(OutputH, color);
SetConsoleCursorPosition(OutputH, position);
cout << szText;
}
You will probably want to check the file anyway, as they comment those lines to tell you what each one's doing.
Oh, yeah, and make sure you #include <windows.h>
And cprintf() CAN print strings. Here's the general idea:
Code:
string my_string;
...
cprintf("%s", my_string.c_str());
...
That is what you meant, right?