Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- change_variable_via_pointer_v1.c
- You can find all my C programs at Dragan Milicev's pastebin:
- https://pastebin.com/u/dmilicev
- */
- #include <stdio.h>
- int main(void)
- {
- int a, b;
- int *pa, *pb;
- a = 2; // initialization
- b = 3;
- printf("\n a = %d \t b = %d \n", a, b);
- pa = &a; // pa is pointer to a. It is memory address where value of a is stored.
- pb = &b;
- *pa = 4; // changing value of a by its pointer pa
- *pb = 5;
- printf("\n a = %d \t b = %d \n", a, b);
- // or, by pointers
- printf("\n a = %d \t b = %d \n", *pa, *pb);
- return 0;
- } // main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement