kyoo0000

print

Sep 23rd, 2020
673
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3.  
  4. int main(void) {
  5.     int len = 10;
  6.     void **data = (void**) calloc(len, sizeof(void*));
  7.  
  8.     for(int i=0; i < len; i++)
  9.         data[i] = calloc(1, sizeof(int));
  10.  
  11.     int n[] = {1,2,3,4,5,6,7,8,9,10};
  12.  
  13.     for(int i = 0; i < len; i++)
  14.         data[i] = &n[i];
  15.  
  16.     for(int i = 0; i < len; i++)
  17.         printf("%p\t%p\t%d\t%d\n", &n[i], data[i], n[i], *(data[i]));
  18.  
  19.     free(data);
  20.  
  21.     return EXIT_SUCCESS;
  22. }
  23.  
RAW Paste Data