Assigning arrays to other arrays

Hi all,

I have an array of numbers whose size is 15. Say, array[15]. At some point, in my code, I want to assign array2 to array by:


if(value1 <= value2)
{
array = array2;
}

where value1 and value2 are calculated based on array1 and array2, respectively.
Is this the proper way to do this? Do i need an index?

Thanks in advance.
You need to assign each individual index from array2 into array:
http://www.cplusplus.com/reference/algorithm/copy/
1
2
3
4
if(value1 <= value2)
{
    std::copy(array2, array2 + 15, array);
}
Thanks for your help first of all. When I used this command, I get the following error:

error: request for member âbeginâ in âarrayâ, which is of non-class type âint [(((long unsigned int)(((long int)numLocation) + -0x00000000000000001)) + 1)]â

How can this be fixed?
Thanks
I don't know, the syntax is correct and it compiles for me:
http://ideone.com/JfiLOQ
Can you show me your entire program?
Topic archived. No new replies allowed.