Trouble manually sorting an array using pointers
<p>I understand this may be a simple process for some of you, but I have been working on this task for the last two weeks and have tried multiple different ways to implement a sorting procedure of an array, in a function, without passing the entire array into the function. I am only allowed to pass a pointer and the size of the array. I'm not looking for the answer to be given to me just some general tips and understanding of passing pointers into functions that control arrays. I've searched the internet and my books but most everything recommends using the premade sort function. however I have to create one myself. Below is, what i feel, the closest i've gotten to the correct code. Any help is greatly appreciated.</p>

<pre><code>#include &lt;iostream&gt;
using namespace std ;
void ptr_sort(int *aptr, int size) ;

int main()
{
int array[5] = { 28, 87, -3, 45, 19 } ;
int size = sizeof(array)/sizeof(array[0]) ;
int a = array[0] ;

cout &lt;&lt; "Original array: " ;

for(a = 0 ; a &lt; size ; a++)
{
    cout &lt;&lt; array[a] &lt;&lt; " " ;
}
cout &lt;&lt; endl ;

ptr_sort(&amp;a, size) ;

cout &lt;&lt; "Sorted array: " ;

for(a = 0 ; a &lt; size ; a++)
{
    cout &lt;&lt; array[a] &lt;&lt; " " ;
}
cout &lt;&lt; endl ;

return 0 ;
}


void ptr_sort(int *aptr, int size)
{
int temp ;
int b = *aptr += 1 ;

for(*aptr = 0 ; *aptr &lt; size ; aptr++)
{
    if ( *aptr &lt; b)
    {
        temp = *aptr ;
        *aptr = b ;
        b = temp ;
    }
}
}
</code></pre>