Skip to content

Instantly share code, notes, and snippets.

@sanofc

sanofc/triple.c Secret

Last active August 29, 2015 14:22

Revisions

  1. sanofc revised this gist Jun 6, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion triple.c
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ int main(void){
    p3=p2;
    for(int i=0;i<2;i++){
    for(int j=0; j<2; j++){
    printf("p2=%p %d\n",p3,*(**p3+i*2+j));
    printf("p[%d][%d]=%p %d\n",i,j,p3,*(**p3+i*2+j));
    }
    }
    }
  2. sanofc created this gist Jun 6, 2015.
    18 changes: 18 additions & 0 deletions triple.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    #include <stdio.h>

    int main(void){
    int *p1[2][2],**p2[2],***p3;
    int i[4]={100,200,300,400};
    p1[0][0]=&i[0];
    p1[0][1]=&i[1];
    p1[1][0]=&i[2];
    p1[1][1]=&i[3];
    p2[0]=p1[0];
    p2[1]=p1[1];
    p3=p2;
    for(int i=0;i<2;i++){
    for(int j=0; j<2; j++){
    printf("p2=%p %d\n",p3,*(**p3+i*2+j));
    }
    }
    }