what type of varible is for HEX

This is a discussion on what type of varible is for HEX within the C Programming forums, part of the General Programming Boards category; Code: #include <stdio.h> #include <windows.h> int main ( void ) { HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE ); WORD wOldColorAttrs; ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,344
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 02: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21