I found the below given code on this very useful link:
http://www.adrianxw.....Consoles4.html
First I think I have to include non-standard windows.h header file. I have questions about the bold statements. For example, system() is a function call and arguments are system dependent. In windows the command to clear the screen is system("cls") but the argument used to clear the screen in Linux would be different (I have been told this).
What is "HANDLE hOut"? If it were a function call then it would have parentheses after it? Is it some kind of declaration such as the one "float x, y,..."?
I understand these three bold lines are related. What is "hOut = GetStdHandle(STD_OUTPUT_HANDLE)"? It has a look of a assignment statement such as "Mean = x+y/2".
Then what about "SetConsoleTextAttribute(hOut, FOREGROUND_RED)"? It has a look of a function because it has parentheses and there are arguments within.
It would be really kind of you if you could help me with these queries. Thanks for your help and time. Please don't forget I'm a beginner, so please keep things simple.
Regards
Jackson
#include <windows.h>
#include <iostream.h>
int main()
{
[b]
HANDLE hOut;
hOut = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hOut, FOREGROUND_RED);
[/b]
cout << "This text is red." << endl;
SetConsoleTextAttribute(hOut, FOREGROUND_GREEN);
cout << "This text is green." << endl;
SetConsoleTextAttribute(hOut, FOREGROUND_BLUE);
cout << "This text is blue." << endl;
return 0;
}


Sign In
Create Account


Back to top









