Thread: Structures and unions

  1. #1
    Registered User
    Join Date
    Jun 2010

    Structures and unions

    I'm trying to define an array of structure type CHAR_INFO with 2000 elements,
    and a union in the same time of an array of 8000 characters.

    CHAR_INFO has already a union inside:
    typedef struct _CHAR_INFO { // chi  
        union {                /* Unicode or ANSI character  */ 
            WCHAR UnicodeChar; 
            CHAR AsciiChar; 
        } Char; 
        WORD Attributes;       // text and background colors 
    I am not able to figure how should I declare the structure with a union to
    have the same area of 8000 bytes usable in both array mode and struct mode.

    If I declare an array of structure type CHAR_INFO:
    CHAR_INFO area_to_write[2000];
    Where do I put the union to use the same area for an array of 8000 characters?

    Thanks for any help you can give me.
    Last edited by frktons; 07-30-2010 at 06:42 AM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    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. Replies: 6
    Last Post: 09-21-2008, 04:18 PM
  2. Structures, Unions and Classes
    By Makoy in forum C++ Programming
    Replies: 2
    Last Post: 02-23-2004, 02:57 PM
  3. Structures - Unions
    By AProg in forum C Programming
    Replies: 16
    Last Post: 05-27-2003, 12:43 AM
  4. Unions and Structures
    By C-Struggler in forum C Programming
    Replies: 4
    Last Post: 03-06-2003, 11:28 AM
  5. Structures and unions
    By Paninaro in forum C Programming
    Replies: 6
    Last Post: 06-21-2002, 01:35 PM