1: #include <stdio.h>
   2: 
   3: /*
   4:  *	Initilization of structure containing a union:
   5:  * "tstlgm.c" actually is illegal anyway, since the structure
   6:  * only has four entries.  This file is more legal.  One set of
   7:  * compiler fixes allow this to compile (even correctly).
   8:  */
   9: 
  10: struct TEST {
  11:     int first;
  12:     int second;
  13:     union UTEST {
  14:         int u_int;
  15:         char *u_cptr;
  16:         int *u_iptr;
  17:     } third;
  18:     int fourth;
  19: };
  20: 
  21: struct TEST test[] = {
  22:     {0},
  23:     {1},
  24:     {1},
  25:     {1},
  26:     {1,2,3,4}, /* was "{1,2,(char *)3,4}," but '82 Ritchie complains */
  27:     {0},
  28:     {1,2,0,0},
  29:     {1,2,0,0},
  30:     {0,0,0,0},
  31:     {1}
  32: };
  33: 
  34: main()
  35: {
  36:     int i;
  37: 
  38:     printf("Size of TEST structure = %d\n",sizeof(struct TEST));
  39:     printf("Size of structure test = %d\n",sizeof(test));
  40: 
  41:     for (i = 0; i < 10; ++i){
  42:         printf("Cycle %d ",i);
  43:         printf("First = %d\tSecond = %d\t",
  44:             test[i].first, test[i].second);
  45:         printf("Union third = %d\t", test[i].third.u_int);
  46:         printf("Fourth = %d\n", test[i].fourth);
  47:     }
  48: }

Defined functions

main defined in line 34; never used

Defined variables

test defined in line 21; used 5 times

Defined struct's

TEST defined in line 10; used 4 times
  • in line 21(2), 38(2)

Defined union's

UTEST defined in line 13; never used
Last modified: 1986-10-21
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: ?E00
Valid CSS Valid XHTML 1.0 Strict