I have multiple arrays of various lenghts defined:
int arr1[] = {1, 2, 3, 4};
int arr2[] = {1, 3, 5, 7, 9};
int arr3[] = {6, 8, 11, 5, 2, 3, 6};
I'm passing these to a function that will do something with each element inside of the array:
void procesArr(int* array, int arrayLen) {
for (int i = 0; i < arrayLen; i++) {
// Do something, like print the value
cout << "array[" << i << "]: " << array[i] << endl;
}
}
Then I can do:
processArr(arr1);
Which results in:
array[0]: 1
array[1]: 2
array[2]: 3
array[3]: 4
But now I want to build a sequence of those individual arrays (the length of the sequence is not constant, can be from 2 to 5 individual arrays):
int seq1[] = {*arr1, *arr2, ..., *arrN};
... and be able to pass that to a function that would do the same. However, without each array's length, a for loop would have no idea what the upper bound of each array is.
The end result I'd like is a function that will take the sequence as argument, then separate and process each individual array, separately. Essentially something like this:
processSequence(seq1) { // I think I need to include sizeof(seq1) here
for (int s = 1; s < [length of seq1]; s++;) {
// process each individual array
for (int a = 1; a < [length of individual array]; a++) {
cout << "seq1[" << s << "][" << a << "]: " << seq[s][a] << endl;
}
}
}
And it would then produce something like:
// First array
seq1[0][0] = 1
seq1[0][1] = 2
seq1[0][2] = 3
seq1[0][3] = 4
// Second array
seq1[1][0] = 1
seq1[1][1] = 3
seq1[1][2] = 5
seq1[1][3] = 7
seq1[1][4] = 9
This is where my lack of programming knowledge shows because I can't figure out how to do this.