I have an array:
int *BC_type_vel;
BC_type_vel = new int [nBou+1];
and a function:
void BC_update (const int type[], float X[]) {
for (int i=1; i<=nBou; ++i) {
if (type[i] == 1) {
std::cout << i << " " << type[i] << " " << BC_type_vel[i] << std:: endl;
for (int e=PSiS[i]; e<PSiE[i]; ++e) {
X[e] = X[elm[e].neigh[0]];
}
}
}
}
I call it as:
BC_update(BC_type_vel,U);
It gives output as:
1 1 0
2 1 0
3 1 0
4 1 1
5 1 0
So why the function argument does not copy values properly?
I tried following code with gcc:
and it gives the expected results:
So the problem is somewhere else in your code. You need to provide us with the rest of it.