1
good night! I have a question about how to copy a vector.
I declared a "matrix [a][j]" vector and I need to take the arithmetic mean only from the values contained in "matrix[a]", so I need to make a copy only of the values "[a]" for an auxiliary vector, and I’m not getting it. I created a function that copies the matrix to another, but this giving error because the main vector is different from the auxiliary.
Follows the code of the copy function:
void copiaMatriz (int matriz[], int vetorAux[]){
int count;
for(count = 0; count < LINHA; count++)
vetorAux[count] = matriz[count]; }
How should I declare the main matrix for it to copy only the elements contained in "[a]"?
Thank you.
Why do you think you need to make a copy? I’m not seeing the general context, but it seems to be totally unnecessary to do this, even if you have the problem may be somewhere else.
– Maniero
you can use the
memcpy
to make a copy of your vector, even though it seems unnecessary in this context.– Brumazzi DB