|  |   Chapter 18Answers to Selected Exercises
2. [was #2]
 
(a) extern(b)
 static(c)
 externandstatic(when applied to a local variable) 
4. [was #4] If fhas never been called previously, the value off(10)will be 0. Iffhas been called five times previously, the value off(10)will be 50, sincejis incremented once per call. 
8. [was #6; modified]
 
(a) xis an array of ten pointers to functions. Each function takes anintargument and returns a character.(b)
 xis a function that returns a pointer to an array of five integers.(c)
 xis a function with no arguments that returns a pointer to a function with anintargument that returns a pointer to afloatvalue.(d)
 xis a function with two arguments. The first argument is an integer, and the second
is a pointer to a function with anintargument and no return value.xreturns a pointer to a function with anintargument and no return value. (Although this example may seem
artificially complex, thesignalfunction—part of the standard C library—has exactly this prototype.
See p. 632 for a discussion ofsignal.) 
10. [was #8]
 
(a) char *(*p)(char *);(b)
 void *f(struct t *p, long int n)(void);(c)
 void (*a[])(void) = {insert, search, update, print};(d)
 struct t (*b[10])(int, int); 
13. [was #10] (a), (c), and (d) are legal. (b) is illegal; the initializer for a variable with static
storage duration must be a constant expression, and i*idoesn't qualify. 
15. [was #12] (a). Variables with static storage duration are initialized to zero by default; variables with
automatic storage duration have no default initial value.
 Copyright © 2008, 1996 W. W. Norton & Company, Inc. All rights reserved.
 |