/* File: types4.c
  On the importance of being typed.
*/

#include <stdio.h>
#define TOP 17

typedef int int_array[TOP] ;

main() {
   int_array A ;
   int_array *ptr1 ;
   int *ptr2 ;
   int i, test ;
   
   ptr1 = &A ;
   ptr2 = &A[0] ;

   for (i = 0 ; i < TOP ; i++) {
      *(ptr2 + i) = i ;
   }

   for (i = 0 ; i < TOP ; i++) {
      ptr2[i] = ptr2[i] * ptr2[i] ;
   }

   for (i = 0 ; i < TOP ; i++) {
      printf("%3d ", A[i]) ;
   }
   printf("\n\n") ;

   printf("sizeof(int) = %d\n", sizeof(int)) ;

   printf("\nBefore:\n") ;
   printf("ptr1 = %u\n", ptr1) ;
   printf("ptr2 = %u\n", ptr2) ;

   ptr1++ ;
   ptr2++ ;

   printf("\nAfter:\n") ;
   printf("ptr1 = %u\n", ptr1) ;
   printf("ptr2 = %u\n", ptr2) ;

}