First off, indent your code. That makes it a whole load more readable, even in simple examples like this!
main( )
{
int s[5][2] = { { 1234, 56 },
{ 1212, 33 },
{ 1434, 80 },
{ 1312, 78 } } ;
int ( *p )[2] ;
int i, j, *pint ;
for ( i = 0 ; i <= 3 ; i++ )
{
p = &s[i] ;
pint = p ;
printf ( "\n" ) ;
for ( j = 0 ; j <= 1 ; j++ )
printf ( "%d ", *( pint + j ) ) ;
}
}
Second, particularly when you are beginning, always use curly brackets, even if they are not needed:
for ( j = 0 ; j <= 1 ; j++ )
{
printf ( "%d ", *( pint + j ) ) ;
}
That way it's harder for you to make a mistake, and assume that code you add is part of the loop.
Thirdly, when you compile that app, you will get a warning: "assignment from incompatible pointer type" because
p
and
pint
are not the same type:
pint is a "pointer to an integer", p is an "array of pointer to integers" - or a "pointer to a pointer to an integer"
And you get different values as a result when you try to print them, if only because *pint is an integer and thus 32 bits long, and *p is pointer and thus 64 bits long.
Don't ignore warnings: at this stage the compiler knows a lot better than you do! (And I do, sometimes - I have my compiler options set to treat warnings as errors so I can;t ignore them. If I get a warning it almost always means I made a mistake, not the compiler!