Hi all,
I'm making a struct like this
Code:
typedef struct{
double *x;
double *y;
}data;
Then I declare a variable of type 'data' in main.
is it alright to allocate memory to x & y (as they are array pointers) I have typed it like this.
Code:
data twoColoumbTable;
numRows = 100;
twoColoumbTable.x = malloc(numRows * sizeof(double));
twoColoumbTable.y = malloc(numRows * sizeof (double));
just wanted confirmation that this is correct thanks
Or should it be more like this
Code:
twoColoumbTable = malloc(2 * numRows * sizeof(double));
but then i cant allocate memory to the individual members.
Am hopeing the way iv done it (first eg) it right.
appreciate the help guys