using pointers insde functions
in the code below i am trying to make a function that will sort an array into numerical order but the syntax i am using below is
wrong. Can anybody tell me what I am doing wrong here .
Thanks!
Code:
#include<iostream>
using namespace std;
void SortArray(int* array);
int main(void)
{
int ages[2]={6,5};
cout << ages[0] << " " << ages[1] << endl;
SortArray(ages);
cout << ages[0] << " " << ages[1] << endl;
return(0);
}
void SortArray(int* array)
{
int temp=0;
int* pnum1=array[0];
int* pnum2=array[1];
if(*pnum1>*pnum2)
{
temp=*pnum1;
*pnum1=*pnum2;
*pnum2=temp;
}