Reputation: 129
I need to create a matrix with 2 columns and unknown number of rows. I know I have to use malloc but I can't find how to declare such matrix. it should hold integers in the first column and doubles in the second. How do I do that?
Upvotes: 0
Views: 201
Reputation: 59997
struct item {
int i;
double d;
};
struct item matrix = malloc(sizeof(struct item) * number_of_rows)
matrix[0].i = 544343;
matrix[0].d = 0.3434343;
Is that the code you are looking for?
Upvotes: 2