Advertisement
Guest User

Untitled

a guest
Jun 7th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. typedef struct
  5. {
  6.     int *p;
  7.     int a;
  8. } foo;
  9.  
  10. int main(int argc, const char * argv[])
  11. {
  12.     foo *temp = (foo*)malloc(sizeof(foo));
  13.  
  14.     int x = 10;
  15.    
  16.    
  17.     temp->p = &x;
  18.     temp->a = 999;
  19.    
  20.     //printf("%x\n", temp->p);
  21.     //printf("%x\n", &x);
  22.     int a = 0;
  23.     void* f = temp;
  24.     for(a;a < 9;a++)
  25.     {
  26.         printf("%d\n", *((int*)(f)));
  27.         f++;
  28.     }
  29.    
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement