Quiz ..............................................................................................................
- What does the term modular programmingmean?
- In modular programming, what is the main module?
- When you define a macro, why should each argument be enclosed in parentheses?
- What are the pros and cons of using a macro in place of a regular function?
- What does the defined()operator do?
- What must always be used if #ifis used?
- What extension do compiled C files have? (Assume that they have not been
linked.) - What does #includedo?
- What is the difference between this line of code:
#include <myfile.h>
and the following line of code
#include “myfile.h” - What is DATEused for?
- What does argv[0]point to?
Exercises ........................................................................................................
Because many solutions are possible for the following exercises, answers are not pro-
vided.
- Use your compiler to compile multiple source files into a single executable file.
(You can use Listings 21.1, 21.2, and 21.3 or your own listings.) - Write an error routine that receives an error number, line number, and module
name. The routine should print a formatted error message and then exit the pro-
gram. Use the predefined macros for the line number and module name. (Pass the
line number and module name from the location where the error occurs.) Here’s a
possible example of a formatted error:
module.c (Line ##): Error number ## - Modify exercise 2 to make the error message more descriptive. Create a text file
with your editor that contains an error number and message. Call this file
ERRORS.TXT. It could contain information such as the following:
1 Error number 1
2 Error number 2
90 Error opening file
100 Error reading file
616 Day 21
33 448201x-CH21 8/13/02 11:16 AM Page 616