Accessing integer variables through pointer variables in C language

Hits: 0

Access [integer] variables through pointer variables

int  main () {
     int a= 100 ,b= 10 ;        //Define integer variables a,b, and initialize 
    int *pointer_1,*pointer_2;        //Define pointer variables pointer_1, pointer_2 
    pointer_1=&a;        //Assign the address of variable a to the pointer variable pointer_l 
    pointer_2=&b;        //Assign the address of variable b to the pointer variable pointer_2 
    printf ( "a=%d,b=%d\n" ,a,b);        / /Output the values ​​of variables a and b 
    printf ( "*pointer_1=%d,*pointer_2=%d\n" ,*pointer_1,*pointer_2);        //Output the values ​​of variables a and b 
    return  0 ;

If you don’t understand, please leave a message, thank you!

You may also like...

Leave a Reply

Your email address will not be published.