fork(1) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int main(void) {
  4. // your code goes here
  5. int a = 1;
  6. int *ptr = &a;
  7.  
  8. /*Print the address pointed to*/
  9. printf("pointing to address: %p\n", ptr );
  10.  
  11. /*Print the value in address*/
  12. printf("Value: %d\n", *ptr );
  13.  
  14. /*Print ptr's addressf*/
  15. printf("Value: %p\n", &ptr );
  16.  
  17. *ptr = 5;
  18. printf("Value: %d\n", a );
  19.  
  20. ptr = NULL;
  21.  
  22. // ERROR
  23. /*Print the value pointed to by ptr*/
  24. // printf("Value: %d\n", *ptr );
  25.  
  26. a = 2;
  27. printf("Value: %d\n", a );
  28. printf("Value: %d\n", sizeof(int) );
  29. return EXIT_SUCCESS;
  30. }
  31.  
Success #stdin #stdout 0s 4280KB
stdin
Standard input is empty
stdout
pointing to address:  0x7ffea18ae35c
Value:  1
Value:  0x7ffea18ae360
Value:  5
Value:  2
Value:  4