Data Structure question

Robert Nelson Gasch rg2c+ at andrew.cmu.edu
Sat Feb 2 10:16:13 AEST 1991


Please excuse me if this is basic, but I'n no C hack and am having
problems with this as I only recently started programming in C. Given 
the following declarations (excuse the long winded format, but this
is the most explicit notation to me)

typedef struct{
	int data, value, frequency;
	} datatype;
	
typedef datatype data_array[MAXNUM];
typedef data_array *data_array_pointer;
typedef data_array_pointer pointer_matrix_type[MAXNUM];


How do I access the individual data elements once I malloc() the structure?
I've been trying to get this right for 2 days by now but managed to produce
only system errors. If this were a simple 2 dimensional array, the notation
would be
    array[x][y].data = whatever;

Introducing pointers into the data structure makes things harder though,
so I have no clue on how to correctly access the cells. If anybody could
shed some light on this, I'd greatly appreciate it.

Thanx a lot ---> Rob



More information about the Comp.lang.c mailing list