1: /*
   2:  * Test for C structures.
   3:  */
   4: 
   5: /*
   6:  * A simple nested structure.
   7:  */
   8: 
   9: struct simple {
  10:     int a;
  11:     char b;
  12:     double c;
  13:     struct {
  14:     int a;
  15:     char b;
  16:     double c;
  17:     } d;
  18:     int e;
  19:     char f;
  20:     double g;
  21: } simple;
  22: 
  23: /*
  24:  * Mutually recursive structures, using typedefs.
  25:  */
  26: 
  27: typedef struct first *First;
  28: typedef struct second *Second;
  29: 
  30: struct second {
  31:     int b;
  32:     char c;
  33: };
  34: 
  35: struct first {
  36:     int a;
  37:     Second p;
  38: };
  39: 
  40: UseRecurStructs()
  41: {
  42:     struct first b, *p;
  43:     struct second list;
  44: 
  45:     p = &b;
  46:     b.a = 3;
  47:     b.p = &list;
  48:     b.p->b = 4;
  49:     b.p->c = 'c';
  50: }
  51: 
  52: /*
  53:  * Functions returning structures.
  54:  */
  55: 
  56: struct simple f(x)
  57: int x;
  58: {
  59:     struct simple s;
  60: 
  61:     s.a = x;
  62:     s.g = 3.14;
  63:     return s;
  64: }
  65: 
  66: main()
  67: {
  68:     struct simple x;
  69:     struct simple *y;
  70: 
  71:     UseRecurStructs();
  72:     x = f(3);
  73:     y = &x;
  74: }

Defined functions

UseRecurStructs defined in line 40; used 1 times
  • in line 71
f defined in line 56; used 2 times
main defined in line 66; never used

Defined variables

simple defined in line 21; never used

Defined struct's

first defined in line 35; used 3 times
second defined in line 30; used 3 times
simple defined in line 9; used 8 times

Defined typedef's

First defined in line 27; never used
Second defined in line 28; used 1 times
  • in line 37
Last modified: 1985-03-08
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 356
Valid CSS Valid XHTML 1.0 Strict