Thread: Create Dynamic Array of Unions

  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
    39,656
    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, 02:33 AM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07: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