Advertisement
teknoraver

sizeof(void)

Oct 16th, 2015
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(int argc, char *args[])
  4. {
  5.     int i;
  6.     int *p = &i;
  7.     void *v = &i;
  8.  
  9.     printf("p:  %p\n", p);
  10.     printf("p+1:    %p\n", p + 1);
  11.     printf("p+2:    %p\n\n", p + 2);
  12.  
  13.     printf("v:  %p\n", v);
  14.     printf("v+1:    %p\n", v + 1);
  15.     printf("v+2:    %p\n\n", v + 2);
  16.  
  17.     printf("sizeof(v):  %u\n", sizeof(v));
  18.     printf("sizeof(*v): %u\n", sizeof(*v));
  19.  
  20.     return 0;
  21. }
  22.  
  23. /*
  24. p:  0xffe1e840
  25. p+1:    0xffe1e844
  26. p+2:    0xffe1e848
  27.  
  28. v:  0xffe1e840
  29. v+1:    0xffe1e841
  30. v+2:    0xffe1e842
  31.  
  32. sizeof(v):  8
  33. sizeof(*v): 1
  34. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement