problem in c..

anksingla

anksingla

@anksingla-ttYJbX Oct 22, 2024
int s[][2]={12,1,13,214,3};

int i,j;
int (*p)[2];
int *pint;
For(i=0;i<3;++i)
{
p=&s;
pint=(int*)p;
for(j=0;j<2;++j)
printf("%d",*(pint+j));
}
This will print values stored in array s.
But in printf statement instead of *(pint+j) if use *(*p+j). Both will print values of s.
How *(pint+j)=*(*p+j)??
Can anyone explain it..?

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • avii

    avii

    @avii-TGGs8o Oct 3, 2014

    <a href="https://www.eskimo.com/~scs/cclass/notes/sx10a.html" target="_blank" rel="nofollow noopener noreferrer">10.1 Basic Pointer Operations</a>
  • Shashank Moghe

    Shashank Moghe

    @shashank-94ap1q Oct 3, 2014

    Explicit typecasting, I believe? The question to follow is, whether it is necessary.
  • anksingla

    anksingla

    @anksingla-ttYJbX Oct 3, 2014

    Shashank Moghe
    Explicit typecasting, I believe? The question to follow is, whether it is necessary.
    i also think so..but in a below program i got confused..
    int s[4][2]