767 B
767 B
4. Suppose that the following declarations are in effect:
struct point {int x, y; };
struct rectangle { struct point upper_left, lower_right; };
struct rectangle *p;
Assume that we want
p
to point to a rectangle structure whose upper left corner is at(10, 25)
, and whose lower right corner is at(20, 15)
. Write a series of statements that allocate such a structure and initialize it as indicated.
struct rectangle rect = { { 10, 25 }, { 20, 15 } };
p = ▭
5. Suppose that
f
andp
are declared as follows:
struct {
union {
char a, b;
int c;
} d;
int e[5];
} f, *p = &f;
Which of the following statements are legal?
(a) p->b = ' ';
(b) p->e[3] = 10;
(c) (*p).d.a = '*';
(d) p->d->c = 20;