a novice C language learning journey(1)

in art •  5 years ago 

Select the large valuo in two Formal parameter in aj function.then take the large valuo pass the value back to the two formal parameters.But program unable to run. the code as follows:
#include<stdio.h>
void aj(int *a,int *b){

if(*a>*b)
    *b=*a;
    else
        *a=*b;

}
int main(void){

int *x;
int *y;
scanf("%d%d",x,y);
aj(x,y);
printf("%d %d",*x,*y);
return 0;

}
after search the cause.So that is it.I did not point to the object with pointer.So i declare an variable for the pointer. Let the pointer point the variable.After modification,the code as follows:
#include<stdio.h>
void aj(int *a,int *b){

if(*a>*b)
    *b=*a;
    else
        *a=*b;

}
int main(void){

int x;
int y;
int *g;
int *h;
g=&x;
h=&y;
scanf("%d%d",g,h);
aj(g,h);
printf("%d %d",*g,*h);
return 0;

}

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Warning! This user is on our black list, likely as a known plagiarist, spammer or ID thief. Please be cautious with this post!
If you believe this is an error, please chat with us in the #appeals channel in our discord.

This is an error, do not add blacklist without basis

talk to them on their discord channel; it's not simple to get removed from the black list, but if you are sure they are wrong, talk to them.