Suppose I have an array
int arr[] = {...};
arr = function(arr);
I have the function as
int& function(int arr[])
{
//
Following works and doesn't seem messy or mis-understandable!
int* returnarray(int a[])
{
for (unsigned int i = 0; i < 3; i++)
{
a[i] *= 2;
}
return a;
}
int main(int argc, char* argv[])
{
int arr[3] = {1,2,3};
int* p = returnarray(arr);
for (unsigned int i = 0; i < 3; i++)
{
cout << "p[" << i << "] = " << p[i] << endl;
}
cin.get();
return 0;
}