I am trying to create an array of structures as well as a pointer to this array. I do not know how large the array is, so it must be dynamic. My structure will look something like this:
typedef struct _stats_t { int hours[24]; int numPostsInHour; int days[7]; int numPostsInDay; int weeks[20]; int numPostsInWeek; int totNumLinesInPosts; int numPostsAnalyzed; } stats_t;
... and I need to have several such structures for each file (unknown amount), which I will analyze. I am not sure how to do this. I don't like the following approach due to array size limitation:
# define MAX 10 typedef struct _stats_t { int hours[24]; int numPostsInHour; int days[7]; int numPostsInDay; int weeks[20]; int numPostsInWeek; int totNumLinesInPosts; int numPostsAnalyzed; } stats_t[MAX];
So how do I create this array? Also, will the pointer to this array look like this?
stats_t stats[]; stats_t *statsPtr = &stats[0];
c arrays struct
Hristo Apr 04 '10 at 21:15 2010-04-04 21:15
source share