Okay, so I am calling function fill_arrays like this:
fill_arrays(&data1, &data2, &size1, &size2);
fill_arrays looks like this:
void fill_arrays(int **data1, int **data2, int *size1, int *size2){
*size1 = get_size(*size1, 1);
*size2 = get_size(*size2, 2);
*data1 = malloc(*size1 * sizeof(int *));
*data2 = malloc(*size2 * sizeof(int *));
input_data(&data1, *size1, 1);
}
In input_data function I would like to assign some numbers to an array:
void input_data(int **data, int size, int index){
*data[5] = 5;
}
The problem is, I am completely lost with pointers... Maybe you can tell me how should I call function input_data in order to be able to assign some numbers to data array?
sizeof(int * )bysizeof(int)and passdata1toinput_datainstead of the reference&data.fill_arrays()to (a) determine the sizes of the arrays being filled, (b) allocate space for arrays size, (c) fill the allocated arrays, and (d) return as out-parameters the arrays and the resultant sizes of each? That is what the prototype offill_arrays()looks like you want or are hoping for. Is that the case?