Hey guys, i was trying my hand at WIN32 Console apps before i move on to Windows programming, to get more of a feel for some of <Windows.h> commands. Anyways, i was trying to make a program that makes colored text. The command i use is long and is annoying to write over and over again, so i was trying to incorporate it into a function, Here is the code...
Code:
#include <iostream>
#include <windows.h>
using namespace std;
HANDLE hout=GetStdHandle(STD_OUTPUT_HANDLE);
void red();
int main()
{
char colortext[20];
cout<<"text to write in red: ";
cin.getline(colortext,20);
red();
cout<<"\n\n"<<colortext;
cin.get();
return 0;
}
void red()
{
GetConsoleTextAttribute(FOREGROUND_RED, hout);
}
Any ideas? Thanks guys!