Thread: what type of varible is for HEX

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    51

    what type of varible is for HEX

    Code:
    #include <stdio.h> 
    #include <windows.h> 
    
    int main ( void )
    {
      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_RED | FOREGROUND_INTENSITY );
      
      printf ( "This is a test\n" );
    
      /*
       * Restore the original colors
       */
      SetConsoleTextAttribute ( h, wOldColorAttrs);
      return 0;
    }


    i found this code in FAQ section... what type of varible should i use to set the color?
    Like this?
    eg :
    Code:
    int foreg;
    .....
    SetConsoleTextAttribute ( h, foreg | FOREGROUND_INTENSITY );

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    WORD wOldColorAttrs;
    SetConsoleTextAttribute ( h, wOldColorAttrs | FOREGROUND_INTENSITY );
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sorting the matrix question..
    By transgalactic2 in forum C Programming
    Replies: 47
    Last Post: 12-22-2008, 03:17 PM
  2. Little Array Difficulty
    By G4B3 in forum C Programming
    Replies: 16
    Last Post: 03-19-2008, 12:59 AM
  3. typename madness
    By zxcv in forum C++ Programming
    Replies: 4
    Last Post: 05-13-2006, 10:35 PM
  4. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM