Advertisement
dmilicev

content_of_an_address_v1.c

Jun 3rd, 2020
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.41 KB | None | 0 0
  1. /*
  2.  
  3.     content_of_an_address_v1.c
  4.  
  5.     Task from Sunshine S
  6.     https://web.facebook.com/sunshines13
  7.  
  8.     https://web.facebook.com/groups/543431102664524/?post_id=1174495746224720&comment_id=1174746769532951&reply_comment_id=1175294896144805&notif_id=1591153540531865&notif_t=group_comment&ref=notif
  9.  
  10.     What is the command if I want to see content of an address?
  11.     Say, I want to see the content of FFFF?
  12.  
  13.     You must know what type of variable is on that address. If it is int then
  14.     int *ip=FFFF;
  15.     printf("%d", *ip);
  16.  
  17.     But, you cant read all memory. Read this
  18.     https://gribblelab.org/CBootCamp/7_Memory_Stack_vs_Heap.html
  19.  
  20.     https://stackoverflow.com/questions/32914298/print-value-and-address-of-pointer-defined-in-function
  21.  
  22.  
  23.     You can find all my C programs at Dragan Milicev's pastebin:
  24.  
  25.     https://pastebin.com/u/dmilicev
  26.  
  27. */
  28.  
  29. #include <stdio.h>
  30.  
  31. int main(void)
  32. {
  33.     int n = 5;
  34.     int *pn;
  35.  
  36.     pn = &n;
  37.  
  38.     printf("\n On hexadecimal address %p is value n = %d \n", (void *)pn, *pn );
  39.  
  40.     printf("\n On decimal address %d is value n = %d \n", (void *)pn, *pn );
  41.  
  42.  
  43.     pn = (void *)0x0022FF18;    // here write hexadecimal address which is on your screen
  44.  
  45.     printf("\n On hexadecimal address %p is value n = %d \n", (void *)pn, *pn );
  46.  
  47.  
  48.     pn = (void *)2293528;       // here write decimal address which is on your screen
  49.  
  50.     printf("\n On decimal address %d is value n = %d \n", (void *)pn, *pn );
  51.  
  52.  
  53.  
  54.  
  55.     return 0;
  56.  
  57. } // main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement