Reputation: 1818
2d array with two different datatypes? (Extending the same for C)
Is there a provision of having a 2D array in C where it can have the list of an id (which is a number) in 1st column and a pointer to a structure instance in 2nd column, instances as:
Array[][2] = {{1,&a3}, {3,&b1}, {8,&b2}}
where a1, a2, a3, and b1, b2, b3 are the instances of structures A and B respectively.
Upvotes: 0
Views: 121
Reputation: 5166
As an array in C by definition can't hold values of different types, you should try it out with an array of structures instead.
Upvotes: 5