I'm not sure I understood you, but:
Code:
#include <stdio.h>
void int_sort(int*,int*);
int main()
{
int val1, *pval1, val2, *pval2;
printf( "Enter two numbers: " );
scanf( "%d %d", &val1, &val2);
pval1 = &val1;
pval2 = &val2;
int_sort(pval1,pval2);
printf("The smaller: %d, and the bigger: %d\n",val2,val1);
return 0;
}
void int_sort( int *pval1, int *pval2 )
{
int tmp;
//this will put the max value in val2 and the smaller in val2
if (*pval1 < *pval2) {
tmp = *pval1;
*pval1 = *pval2;
*pval2 = tmp;
}
}
And you don't need pval1 and pval2 here, this could be like this too:
Code:
#include <stdio.h>
void int_sort(int*,int*);
int main()
{
int val1,val2;
printf( "Enter two numbers: " );
scanf( "%d %d", &val1, &val2);
int_sort(&val1,&val2);
printf("The smaller: %d, and the bigger: %d\n",val2,val1);
return 0;
}
void int_sort( int *pval1, int *pval2 )
{
int tmp;
//this will put the max value in val2 and the smaller in val2
if (*pval1 < *pval2) {
tmp = *pval1;
*pval1 = *pval2;
*pval2 = tmp;
}
}
But maybe you want something special, I don't know.
Ahh and you need somechanges to see if they're equal