Tilbage til slide -- Tastaturgenvej: 'u'  forrige -- Tastaturgenvej: 'p'                point-rect.c - Et udvidet eksempel på structures i structures.Lektion 9 - slide 13 : 29
Program 2

#include <stdio.h>

struct point {
  int x;
  int y;
};

struct rect {
  struct point p1;
  struct point p2;
};

struct another_rect {
  struct {
    int x;
    int y;
  }  p1;
  struct {
    int x;
    int y;
  }  p2;
};

int main(void) {

  struct point pt1, pt2;
  struct rect r;
  struct another_rect ar;

  pt1.x = 5; pt1.y = 6;
  pt2.x = 17; pt2.y = 18;

  r.p1 = pt1; r.p2 = pt2;

  ar.p1.x = 1;   ar.p1.y = 2;
  ar.p2.x = 10;  ar.p2.y = 12;

  ar.p1 = pt1;  /* error: incompatible types */
  ar.p2 = pt2;  /* error: incompatible types */

  return 0;
}