I'm working with some C++, and I'd like to understand why the following works.
I have an index:
long long I;
And an array:
double *arr = (double *) malloc(sizeof(double)*100);
It looks like arr + I
shifts the index of arr
. So, for example, if I=1
then the outcome of this line is arr[1:]
. Why is this?
Also, if I have an array of arrays (ex below), what should the shape of I
be?
double **arr = (double **) malloc(sizeof(double *)*2);
for (k = 0; k < num_time_series; k++) {
arr[k] = (double*) malloc(100 * sizeof(double));