hello all!!! i need your help to explain these codes for me because i may need to viva soon....thanks!!!
1.) here are codes, i am using arrow keys to control my menu...as i know the 72 is for arrow key up and 80 is for arrow key down. but y do need the function below that add 256 to my arrows code???
Code:
int get_code ( void )
{
int ch = getch();
if ( ch == 0 || ch == 224 )
ch = static_cast<int>(256 + getch());
return ch;
}
while ( ( ch = get_code() ) != 27 )
{
switch ( ch ) {
case 256 + 72://arrow key up}
}
2. )i also use the code below to change the particular line of my program to make it look more attractive. but i dun really understand wat does the handle h mean. wat is the h??
Code:
int main ( void )
{
HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE );//line 1
WORD wOldColorAttrs;//line2
CONSOLE_SCREEN_BUFFER_INFO csbiInfo; //line3
GetConsoleScreenBufferInfo(h, &csbiInfo);//line4
wOldColorAttrs = csbiInfo.wAttributes; //line5
SetConsoleTextAttribute ( h, FOREGROUND_RED | FOREGROUND_INTENSITY );
printf ( "This is a test\n" );
SetConsoleTextAttribute ( h, FOREGROUND_BLUE| FOREGROUND_INTENSITY );
printf ( "This is a test\n" );
SetConsoleTextAttribute ( h, wOldColorAttrs);
return 0;
}
is anyone out there can explain line 1, 2, 3, 4 and 5 for me?? thanks!!
thanks guys first.....ur guys will give me a big help on my viva....thanks!!!