반응형
#include 
#define print(imsi) printf(#imsi"\t%08x %d\n", imsi,sizeof(imsi))

void bit_pointer_3_1()
{
	int imsi[3][2]={{6,3},{9,1},{7,2}};
    int (*imsip)[2];
    int i,j;
    imsip=imsi;
    for(i=0;i<3;i++)
       for(j=0;j<2;j++)
          printf("[ %d ][ %d ] %d\n",i,j,*(*(imsip+i)+j));
    for(i=0;i<3;i++)
       for(j=0;j<2;j++)
          printf("[ %d ][ %d ] %d\n",i,j,*(imsip[i]+j));
    for(i=0;i<3;i++)
       for(j=0;j<2;j++)
          printf("[ %d ][ %d ] %d\n",i,j,imsip[i][j]);
    for(i=0;i<3;i++)
       for(j=0;j<2;j++)
          printf("[ %d ][ %d ] %d\n",i,j,imsi[i][j]);
}
void bit_pointer_3_2()
{
	int imsi[2];
    int *imsip;
    printf("%d\n",sizeof(imsi));
    printf("%d\n",sizeof(imsip));
    printf("%d\n",sizeof(*imsip));
}
void bit_pointer_3_3()
{
	int imsi[2][3];
    int (*imsip)[3];
    printf("%d\n",sizeof(imsi));
    printf("%d\n",sizeof(imsip));
    printf("%d\n",sizeof(*imsip));
}
void bit_pointer_3_4()
{
	int imsi[3][2]={{3,5},{12,54},{534,923}};
    int (*imsip)[2];
    imsip=imsi;
    imsip=imsi[0];
    imsip=&imsi[0][0];
}
void bit_pointer_3_5()
{
	int imsi[3][2]={{3,5},{12,54},{534,923}};
    printf("imsi %d byte\n",sizeof(imsi));
    printf("imsi[0] %d byte\n",sizeof(imsi[0]));
    printf("&imsi[0][0] %d byte\n",sizeof(&imsi[0][0]));
}
void bit_pointer_3_6()
{
	void temp(int (*)[]);
    int imsi[2][3]={{67,4,7},{7,4,32}};
    int (*imsip)[3];
    imsip=imsi;
    temp(imsip);
}
void bit_pointer_3_7()
{
	int imsi[3][2]={{3,5},{12,54},{534,923}};
    int (*imsip)[2];
    imsip=imsi;
    printf("%#010x %#010x\n",*imsip,*imsip+0);
    printf("%#010x %#010x\n",*(imsip+1),*imsip+1);
    printf("%#010x %#010x\n",*(imsip+2),*imsip+2);
}
void bit_pointer_3_8()
{
	int imsi[3][2]={{6,3},{5,9},{8,2}};
    int (*imsip)[2]=imsi;
    printf("%#010x\n",imsip+0);
    printf("%#010x\n",imsip+1);
    printf("%#010x\n",imsip+2);
    printf("%#010x\n",*(imsip+0));
    printf("%#010x\n",*(imsip+1));
    printf("%#010x\n",*(imsip+2));
}
void bit_pointer_3_9()
{
	int imsi[3][2]={{6,3},{5,9},{8,2}};
    int (*imsip)[2]=imsi;
    printf("%d\n",sizeof(imsip+0));
    printf("%d\n",sizeof(imsip+1));
    printf("%d\n",sizeof(imsip+2));
    printf("%d\n",sizeof(*(imsip+0)));
    printf("%d\n",sizeof(*(imsip+1)));
    printf("%d\n",sizeof(*(imsip+2)));
}
void bit_pointer_3_10()
{
	int imsi[3][2]={{3,2},{5,6},{12,43}};
    int *imsip;
    imsip=&imsi[0][0];
}
void bit_pointer_3_11()
{
	int imsi[3][2]={{3,2},{5,6},{12,43}};
    int *imsip;
    imsip=&imsi[0][0];
    printf("%d\n",**imsip);
    printf("%d\n",*(imsip[1]+0));
}
void bit_pointer_3_12()
{
	int imsi[3][2] = {{3,2},{5,6},{12,43}};
    int *imsip;
    imsip=&imsi[0][0];
    printf("%d\n",*imsip);
    printf("%d\n",*(imsip+1));
    printf("%d\n",*(imsip+2));
    printf("%d\n",*(imsip+3));
}
void bit_pointer_3_13()
{
	int (*imsip)[2];
    int *temp[2];
    printf("&imsip %#010x\n",&imsip);
    printf("&temp[0] %#010x\n",&temp[0]);
    printf("&temp[1] %#010x\n",&temp[1]);
}
void bit_pointer_3_14()
{
	 int imsi[3][2]={{3,5},{12,54},{534,923}};
    int (*imsip)[2];
    int *temp[3];
    imsip=imsi;
    imsip=&imsi[0][0];
    temp[0]=imsi;
    temp[0]=imsi[0];
    temp[1]=imsi[1];
    temp[2]=imsi[2];
    temp[0]=*(imsi+0);
    temp[1]=*(imsi+1);
    temp[2]=*(imsi+2);
    *temp=imsi[0];
    *(temp+0)=imsi[0];
    *(temp+1)=imsi[1];
    *(temp+2)=imsi[2];
    *temp=*imsi;
    *(temp+0)=*(imsi+0);
    *(temp+1)=*(imsi+1);
    *(temp+2)=*(imsi+2);
}
void bit_pointer_3_15()
{
	int imsi_1[2]={5,7};
    int imsi_2[3]={45,67,25};
    int imsi_3[4]={27,34,87,25};

    int *temp[3];

    temp[0]=imsi_1;
    temp[1]=imsi_2;
    temp[2]=imsi_3;

    print(temp);
    print(&temp);
    print(*temp);
    print(temp[0]);
    print(&temp[0]);
}


void main()
{
	 bit_pointer_3_1();
}

'C, C++' 카테고리의 다른 글

[C] 포인터 공부 5  (0) 2014.11.18
[C] 포인터 공부 4  (0) 2014.11.18
[C] 포인터 공부 2  (0) 2014.11.18
[C] 포인터 공부 1  (0) 2014.11.18
[C] C언어의 콘솔환경 (주차장, 단어장 만들기)  (0) 2014.11.18

+ Recent posts