Curso de Programación en C/Prog75

De WikiCabal
Saltar a: navegación, buscar

Prog75

#include <stdio.h>

int main( void )
{
  int zippo[4][2] = { {2,4}, {6,8}, {1,3}, {5, 7} };
  int (*pz)[2];
  pz = zippo;

  printf("   pz = %p,    pz + 1 = %p\n",
             pz,         pz + 1);
  printf("pz[0] = %p, pz[0] + 1 = %p\n",
          pz[0],      pz[0] + 1);
  printf("  *pz = %p,   *pz + 1 = %p\n",
            *pz,        *pz + 1);
  printf("pz[0][0] = %d\n", pz[0][0]);
  printf("  *pz[0] = %d\n", *pz[0]);
  printf("    **pz = %d\n", **pz);
  printf("      pz[2][1] = %d\n", pz[2][1]);
  printf("*(*(pz+2) + 1) = %d\n", *(*(pz+2) + 1));

  return 0;
}

Resultado

[rrc@Pridd CClase]$ gcc -Wall -o Prog75 Prog75.c
[rrc@Pridd CClase]$ ./Prog75
   pz = 0xbfd6ca6c,    pz + 1 = 0xbfd6ca74
pz[0] = 0xbfd6ca6c, pz[0] + 1 = 0xbfd6ca70
  *pz = 0xbfd6ca6c,   *pz + 1 = 0xbfd6ca70
pz[0][0] = 2
  *pz[0] = 2
    **pz = 2
      pz[2][1] = 3
*(*(pz+2) + 1) = 3

Explicación