A
andre.koskamp
Hello,
Is there a possibility to initiate an array with more types, say int's
and char's? I think it is possible to dynamically make a multi
dimensional array, and then typecast the return value of malloc()
function:
int **array = (int **)malloc(ROWS * sizeof(int *));
for(i = 0; i < ROWS; i++)
array[0] = (int *)malloc(sizeof(int));
array[1] = (char *)malloc(sizeof(char));
array[2] = (float *)malloc(sizeof(float));
etc.
Is this a correct way to do this?
If not could someone explain?
Thanks for your advises.
Is there a possibility to initiate an array with more types, say int's
and char's? I think it is possible to dynamically make a multi
dimensional array, and then typecast the return value of malloc()
function:
int **array = (int **)malloc(ROWS * sizeof(int *));
for(i = 0; i < ROWS; i++)
array[0] = (int *)malloc(sizeof(int));
array[1] = (char *)malloc(sizeof(char));
array[2] = (float *)malloc(sizeof(float));
etc.
Is this a correct way to do this?
If not could someone explain?
Thanks for your advises.