I don't see where I have made an error in this code :
void swap(int* a, int* b)
{
int temp = *a;
*a = *b;
*b = temp;
}
void array_reverse(int *begin, int *end)
{
int *end2 = end;
int *q = 0;
for (q = begin; q < end; q += 1)
{
swap(q, end2);
end2 -= 1;
}
}
it should reverse the array:
arr{ 1, 2, 3}
becomes:
arr{ 3, 2, 1}
My output:
[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
becomes :
[111009824, 2, 3, 4, 5, 6, 7, 8, 9, 10]
(well actually this first element always changes each time I compile and test my function and gives me random values I guess )