fork download
  1. #include <stdio.h>
  2. int main()
  3. {
  4. int a = 10; /* a is a variable of type integer */
  5.  
  6. int *int_ptr; /* int_ptr is a variable which is a pointer to variables of type integer */
  7.  
  8.  
  9. int_ptr = &a; /* put the address (not the contents) of a into the variable int_ptr*/
  10.  
  11. /* since addresses in memory can be quite long, its best */
  12. /* to print them in long hexidecimal format */
  13. printf ("%i %lx %x %lx %i \n", a, &a, int_ptr, &int_ptr, *int_ptr);
  14.  
  15. int x = 5;
  16. int *ptr;
  17. *ptr = x;
  18. int *xptr = &x;
  19.  
  20. printf("%i, %i, %i, %xl, %xl, %xl, %xl", x, *ptr, *xptr, &x, ptr, &ptr, xptr);
  21.  
  22.  
  23. return (0);
  24.  
  25. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
10 7ffe986ddff0 986ddff0 7ffe986ddff8 10 
5, 5, 5, 986ddff4l, 986de0f0l, 986de000l, 986ddff4l