#include <iostream>
void foo( int arr[], int N ) {
for ( int i = 0; i < N; ++i ) {
arr[i] = 2*i;
}
}
int main() {
int array[5] {};
// before
for ( auto x : array ) {
std::cout << x << ' ';
}
std::cout << '\n';
foo( array, 5 );
// after
for ( auto x : array ) {
std::cout << x << ' ';
}
std::cout << '\n';
return 0;
}
Since you say this function works on its own, then presumably the problem is not with the code you posted. How about posting the code you're having a problem with and an explanation of the problem you're having?