0
How to pass the reference of arrays to a function?
How to pass the reference of arrays to a function
2 ответов
+ 3
Use a pointer
+ 1
Like this:
void foo(int *pArr)
{
pArr[2] = 6;
}
int main() {
int arr[] = {1, 2, 3};
foo(arr);
cout << arr[2];
return 0;
} // Output: 6