Thread: Variables deluxe.

  1. #1
    Registered User
    Join Date
    Nov 2004
    Posts
    20

    Variables deluxe.

    I would like to have pointed out what the code below means.


    Code:
    int x:4;
    /Netstar

  2. #2
    Registered User
    Join Date
    Oct 2003
    Posts
    9
    It specifies the number of bits used by the struct member (only possible within structs).

    Example: (copied from MSDN help).

    Code:
    struct CELL             // Declare CELL bit field
    {
       unsigned character  : 8;  // 00000000 ????????
       unsigned foreground : 3;  // 00000??? 00000000
       unsigned intensity  : 1;  // 0000?000 00000000
       unsigned background : 3;  // 0???0000 00000000
       unsigned blink      : 1;  // ?0000000 00000000
    };

  3. #3
    Registered User
    Join Date
    Nov 2004
    Posts
    20
    Ok, I guessed it was something like that. But I did'nt know that it could only be used within structs.

    Thanks and sorry for not reading the manual.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. basic question about global variables
    By radeberger in forum C++ Programming
    Replies: 0
    Last Post: 04-06-2009, 12:54 AM
  2. Best way to avoid using global variables
    By Canadian0469 in forum C++ Programming
    Replies: 7
    Last Post: 12-18-2008, 12:02 PM
  3. Replies: 15
    Last Post: 09-30-2008, 02:12 AM
  4. esbo's data sharing example
    By esbo in forum C Programming
    Replies: 49
    Last Post: 01-08-2008, 11:07 PM
  5. Global Variables
    By Taka in forum C Programming
    Replies: 34
    Last Post: 11-02-2007, 03:25 AM