how to assign an array returned by a c++ function code example
Example 1: cpp return array
int * fillarr(int arr[], int length){
for (int i = 0; i < length; ++i){
// arr[i] = ? // do what you want to do here
}
return arr;
}
// then where you want to use it.
int main(){
int arr[5];
int *arr2;
arr2 = fillarr(arr, 5);
}
// at this point, arr & arr2 are basically the same, just slightly
// different types. You can cast arr to a (char*) and it'll be the same.
Example 2: return array of string in function c++
delete[] names;