Programming in C

(Barry) #1
448 Appendix A C Language Summary

In each case, the type of the result is the type of the elements contained in a. See
Section 5.15 for a summary of operations with pointers and arrays.

5.14 Basic Operations with Structures^1
Given that
x is a modifiable lvalue expression of type struct s;
y is an expression of type struct s;
m is the name of one of the members of the structure s;
v is an expression;
then the expression
x references the entire structure and is of type struct s;
y.m references the member mof the structure yand is of the type declared
for the member m;
x.m = v assigns vto the member mof xand is of the type declared for the
member m;
x = y assigns yto xand is of type struct s;
f (y) calls the function f, passing contents of the structure yas the argu-
ment; inside f, the formal parameter must be declared to be of type
struct s;
return y; returns the structure y;the return type declared for the function must
be struct s.

5.15 Basic Operations with Pointers


Given that
x is anlvalueexpression of type t;
pt is a modifiable lvalue expression of type “pointer to t”;
v is an expression;
then the expression
&x produces a pointer to xand has type “pointer to t”;
pt = &x sets ptpointing to xand has type “pointer to t”;
pt = 0 assigns the null pointer to pt;
pt == 0 tests to see if ptis null;
*pt references the value pointed to by ptand has type t;
*pt = v stores the value of vinto the location pointed to by ptand has type t.


  1. Also applies to unions.


20 0672326663 AppA 6/10/04 2:01 PM Page 448

Free download pdf