Hi all,
I'm not really sure what to make of this. I just hope it has a simple explanation haha.
I have the following function:
int splitRecDataByComma(int *data_deposit_array)
{
int i = 0;
char buff[6];
int * ptr_data_deposit[4];
//Assign pointers to the deposit
ptr_data_deposit[0] = data_deposit_array;
ptr_data_deposit[1] = (data_deposit_array + 1);
ptr_data_deposit[2] = (data_deposit_array + 2);
ptr_data_deposit[3] = (data_deposit_array + 3);
//Do something with the pointers e.g.
*ptr_data_deposit[1] = atoi(buff);
}
Ignoring what the function actually does, this works just fine. The purpose of the pointers is that I will be changing the number of variables passed over in the array 'data_deposit_array'.
However, I now change the pointer declarations to the following and it falls over:
int splitRecDataByComma(int *data_deposit_array)
{
int i = 0;
char buff[6];
int * ptr_data_deposit[4];
//Assign pointers to the deposit
for(i=0;i<4;i++){
ptr_data_deposit[i] = data_deposit_array + i;
}
//Do something with the pointers e.g.
*ptr_data_deposit[1] = atoi(buff);
}
I don't get why it doesn't work... Does anyone know what am I missing??
Much appreciated