Hello again, are there any co
nsiderations when reusing arrays?. By reusing I mean assigning a new set of values after already declaring and using once?
Int B1 = {3,4,5,6,7}; // declared and used once
Then ideally I would like to do something like this
B1[]={10,12,13,15,20}; // my compiler doesn't like this?
Alternatively you can use a temporary array, then copy the values back into the original, and hope the optimizer can inline the std::copy call, and unroll the loop.
I'm quite surprised by that?? ,I thought there would be a way, just I didn't know how!
Can the addresses of each element in the array be accessed by pointer manipulation?
you can copy elements of one data onto other by following way -
1 2 3 4 5 6 7
int array[5] = {1,2,3,4,5};
int temp[5] = {6,7,8,9,10};
for(int i =0;i<5;i++)
{
array[i] = temp[i];
}
B1[]={10,12,13,15,20}; // my compiler doesn't like this?
That is illegal, when declaring an array you must specify the size which would remain fixed throughout the prorgam.