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

#include <stdio.h>

typedef int int_array[3] ;

typedef struct {
    int_array array ;
    int n ;
} record ;

main() {
   record R ;
   record *ptr1 ;
   int_array *ptr2 ;
   int *ptr3 ;
   int test ;
   
   ptr1 = &R ;
   ptr2 = &(R.array) ;
   ptr3 = &(R.array[0]) ;

   printf("ptr1 = %p\n", ptr1) ;
   printf("ptr2 = %p\n", ptr2) ;
   printf("ptr3 = %p\n", ptr3) ;

   R.array[0] = 7 ;

   test = (*ptr1).array[0] ; 
   printf("(*ptr1).array[0] = %d\n", test) ;

   test = (*ptr2)[0] ;
   printf("(*ptr2)[0] = %d\n", test) ;

   test = *ptr3 ;
   printf("*ptr3 = %d\n", test) ;

}
