The 'array' is a pointer to an array. More specifically to first element of the array. The array has 'size' elements.
Dereferencing the pointer we can reach the individual elements / their values.
is the first element
is the last
then? An out of range error, for we have no idea what is in that memory.
You, however, do not access that non-existent element in main(). You merely take its address
. That too could be a violation.
There is an another, "pointer math" syntax for dereferencing an element:
Taking address is thus:
But why dereference and then take address, when the address is already there before referencing:
What goes wrong?
You give address
to a function that thinks that the address is of first element in size-long array. It is not. The first element of the array that you have allocated is at
Rewrite line 55:
sortAscend( array, size );
* You have two loops in main(). Both loop through the array. Why do they use different loop counter?
is old macro. Current C++ has
that has subtle benefits.
int sortAscend(int arraySort, int sortSize)
// means same as
int sortAscend(int * arraySort, int sortSize)