|
|
|
Chapter 24Answers to Selected Exercises4. [was #2] (a) double try_math_fcn(double (*f)(double), double x, const char *msg) { double result; errno = 0; result = (*f)(x); if (errno != 0) { perror(msg); exit(EXIT_FAILURE); } return result; } (b) #define TRY_MATH_FCN(f,x) try_math_fcn(f, x, "Error in call of " #f) 5. [was #4] int main(void) { char code; for (;;) { setjmp(env); printf("Enter operation code: "); scanf(" %c", &code); while (getchar() != '\n') /* skips to end of line */ ; switch (code) { case 'i': insert(); break; case 's': search(); break; case 'u': update(); break; case 'p': print(); break; case 'q': return 0; default: printf("Illegal code\n"); } printf("\n"); } }
The Copyright © 2008, 1996 W. W. Norton & Company, Inc. All rights reserved. |