- I've been using two header files to color my text.
- The first one color_green.h saves the original color settings and then sets the new colors (green text).
- And second one called restore_color resets to original colors.
Code:// This is the header "color_green.h" HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE ); WORD wOldColorAttrs; CONSOLE_SCREEN_BUFFER_INFO csbiInfo; /* * First save the current color information */ GetConsoleScreenBufferInfo(h, &csbiInfo); wOldColorAttrs = csbiInfo.wAttributes; /* * Set the new color information */ SetConsoleTextAttribute ( h, FOREGROUND_GREEN | FOREGROUND_INTENSITY ); /*************************************************/ // This is the header "restore_color.h" /* * resets to the original colors */ SetConsoleTextAttribute ( h, wOldColorAttrs);
This has been working. But then my compiler has started giving me the error messages(both of them in "restore_color.h") :
error: 'h' undeclared (first use in this function) &
error: 'wOldColorAttrs' undeclared (first use in this function)
Why am I getting error messages?