Thread: Storing an Array that is Dynamically Allocated of a Struct

  1. #1
    Registered User
    Join Date
    May 2013
    Dallas, Texas

    Storing an Array that is Dynamically Allocated of a Struct

    I'm trying to read in a file and store it in an array that is dynamically allocated of a struct (which I'm not sure how to do), then parse each line using strtok() from string.h.
    The idea is to separate the lines by date, subject, time, etc.

    Since the array is a dynamically allocated of typdef struct, it's sorted by the date of each struct, with an intial size of 25. But whenever the array needs to be resized, it should be doubled.

    Any tips on what to do?
    Sorry for the question may seem unclear. Let me know if you need clarification.


  2. #2
    Registered User
    Join Date
    Apr 2013
    Would using realloc() to increase the size of the array of structures as needed help here?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dynamically Allocated Array
    By chris4 in forum C Programming
    Replies: 9
    Last Post: 05-06-2011, 10:01 AM
  2. Dynamically Allocated Array
    By vb.bajpai in forum C Programming
    Replies: 3
    Last Post: 06-17-2007, 08:40 AM
  3. storing dynamically allocated pointers
    By breaka in forum C Programming
    Replies: 19
    Last Post: 07-22-2006, 06:01 AM
  4. Replies: 10
    Last Post: 05-18-2006, 11:23 PM
  5. File I/O problem for dynamically allocated struct array
    By veecee in forum C++ Programming
    Replies: 2
    Last Post: 05-05-2006, 09:28 PM