Hey I'm trying to switch the two parameters around only when parameter 1 is greater than parameter 2.
What I've got so far is this:
#include <stdio.h>
void ascending2(int*, int*);
int main(void){
int ptr1 = 20;
int ptr2 = 10;
printf("ptr1 = %d, ptr2 = %d", ascending2(&ptr1, &ptr2));
return 0;
}
void ascending2(int *ptr1, int* ptr2){
int *value;
if( *ptr1 >= *ptr2 ){
*value = *ptr1;
*ptr1 = *ptr2;
*ptr2 = *value;}
}
Can anyone suggest where I may be going wrong, thanks.
ptr1andptr2inmain()are really bad.