Create Dynamic Array of Unions

This is a discussion on Create Dynamic Array of Unions within the C++ Programming forums, part of the General Programming Boards category; I have a binary file containing an unknown number of unions which must be read into a dynamically created array ...

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    6

    Red face Create Dynamic Array of Unions

    I have a binary file containing an unknown number of unions which must be read into a dynamically created array for further processing and sorting.
    Can anyone help with the syntax for this????????

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,855
    Well it's like this
    http://www.cprogramming.com/cboard/s...threadid=17666

    Only you use read() instead of write()
    And you open the file for input.

    If you want to know how many array elements to allocate, and all the unions in the file are the same size, then just divide the file size by the sizeof() of the union.

    Then use the new operator to allocate some memory (see past posts ad-nauseum)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. dynamic array of pointers?
    By baniakjr in forum C++ Programming
    Replies: 3
    Last Post: 12-29-2006, 09:46 AM
  2. dynamic array
    By linuxdude in forum C Programming
    Replies: 5
    Last Post: 07-13-2004, 03:33 AM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 10:54 AM
  4. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 08:48 PM
  5. Type and nontype parameters w/overloading
    By Mr_LJ in forum C++ Programming
    Replies: 3
    Last Post: 01-02-2004, 01:01 AM

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