Sep 23, 2010 at 10:37pm UTC
Because SetConsoleTextAttribute( consoleHANDLE, 20) function gets called - and returns
a value of true or false - and it is this return value that is displayed ( 1 for true or 0 for false)
Sep 23, 2010 at 10:39pm UTC
so.. dont put it in between one cout is what you mean?
Sep 23, 2010 at 10:42pm UTC
Yeah, that's what he meant.
1 2 3 4 5 6 7 8 9
cout<<"\311\315\315\315\315\315\315\315\315\315\315\315\315\315\315\315\315\315\315\315\315\315\273"
<<"\n\272" ;
SetConsoleTextAttribute( consoleHANDLE, 20);
cout <<"Hit ENTER to continue\272"
<<"\n\310\315\315\315\315\315\315\315\315\315\315\315\315\315\315\315\315\315\315\315\315\315\274" ;
cin.ignore();
that will work.
Last edited on Sep 23, 2010 at 10:43pm UTC
Sep 23, 2010 at 10:43pm UTC
Okay thank you. I have never received a good explanation about what return is so i just told myself to ignore it untill I get to higher levels.
Sep 23, 2010 at 10:47pm UTC
While I'm here, anyone can explain to me how I can figure out what my color will turn out without trial and error?
Sep 23, 2010 at 10:48pm UTC
http://cplusplus.com/doc/tutorial/functions/
That will explain functions very well.
Functions have a type, just like '250' could be an int.
so if i had a function that looked like this
1 2 3 4 5 6 7 8 9 10
int Return500()
{
return 500;
}
//then in main i did this
int main()
{
cout << Return500() << endl; //the console will output '500', because the function is.. sort of a value itself.
}
The same applies to any other type of data
1 2 3 4 5 6 7 8 9
std::string ReturnHello()
{
std::string str = "Hello" ;
return str; //returns str, which equals "Hello"
}
//......
cout << ReturnHello() << endl; //would output "Hello"
EDIT: And sure, i'll explain
1 2 3 4
BOOL WINAPI SetConsoleTextAttribute(
__in HANDLE hConsoleOutput,
__in WORD wAttributes
);
The first parameter is the handle to the console
WORD wAttributes is the color. Different color attributes you can use are here:
http://msdn.microsoft.com/en-us/library/ms682088%28v=VS.85%29.aspx#_win32_character_attributes
Example: to set the background to blue and the foreground to red, you'd use
SetConsoleTextAttribute(consoleHANDLE, BACKGROUND_BLUE | FOREGROUND_RED);
Last edited on Sep 23, 2010 at 10:56pm UTC