Here's a quick refresher on what the [] operator does:
a[b] is the same as *(a + b).
Therefore you could more tidily write your code snippet as this:
Code:
for( counter = 0; counter < 3; ++counter ) {
array[counter] = sourcePointer[counter];
}
Or perhaps you could simply use memcpy:
Code:
memcpy(array, sourcePointer, 3 * sizeof(array[0]));
Of course if these were objects you were copying, you'd have to use std::copy instead. In fact it's not a bad idea anyway:
Code:
std::copy(array, &sourcePointer[0], &sourcePointer[3]);
As often happens, I wont yet be giving you any furthur optimisation advice here because you aren't yet giving us the big picture of what you're doing. You'd have to post more than your one little loop. The whole function it's in would be a good start.