Cooler_

test multi ptrs

Sep 1st, 2014
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. int main()
  6. {
  7.  
  8.  
  9.  char ***lists=(char ***)malloc( 2*sizeof(char **)   );
  10.  
  11.  
  12.  *(lists+0)=(char **)malloc(3*sizeof(char *));
  13.  
  14.  *(*(lists+0)+0)="ola";
  15.  *(*(lists+0)+1)="Yay";
  16.  *(*(lists+0)+2)="lol";
  17.  
  18.  lists[0][3]=(char *)realloc(lists[0],4*sizeof(char *));
  19.  *(*(lists+0)+3)="iai";
  20.  
  21.  *(lists+1)=(char **)malloc(3*sizeof(char *));
  22.  *(*(lists+1)+0)="epic";
  23.  *(*(lists+1)+1)="let";
  24.  *(*(lists+1)+2)="omg";
  25.  
  26.  fprintf(stdout," %s \n %s \n %c\n",lists[0][2],lists[1][0],lists[0][0][1]);
  27.  
  28.  
  29.  free(lists[0]);
  30.  free(lists[1]);
  31.  free(lists);
  32.  
  33.  return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment