0

How to pass the reference of arrays to a function?

How to pass the reference of arrays to a function

1st Jan 2019, 1:51 PM
Aamir Mehmood
2 odpowiedzi
+ 3
Use a pointer
1st Jan 2019, 1:59 PM
ShortCode
+ 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
1st Jan 2019, 2:10 PM
Sekiro
Sekiro - avatar