Hello folks, just a quick question regarding initialising an array to contain other arrays.
The problem I'm encountering is that I want to fill different elements of a large array (called "holder") with a smaller array (called "arr") which changes within each iteration of a loop.
Below kind of what I was thinking of doing;
Code:
int L = 31;
int n = 5;
int* arr;
arr = (int*)malloc(L*sizeof(int));
// Here I need to initialise "holder", but I'm not sure how
for (i = 0; i < n; i++) {
while (val <= 0) {
arr = GenerateArray(L);
val = CalculateVal(arr);
}
holder[something][something] = something
}
Filling "arr" and using it as a stand-alone array is fine, but the problems I'm coming across are that I don't know how to initialise "holder", and then I don't know how to properly put "arr" into a cell (or across many?) within it.
Some extra information, not sure if it will help or not.
- "arr" is of length L, a non-constant variable
- L is the first dimension of "holder"
- n is the number of iterations of the loop, and as such the second dimension of "holder"
Any help and advice is appreciated, cheers