Sams Teach Yourself C in 21 Days

(singke) #1
620 Week 3

LISTINGR3.1 week3.c. Week 3’s review listing
1: /* Program Name: week3.c */
2: /* Program to keep track of names and phone numbers. */
3:
4: /* Information is written to a disk file specified */
5: /* with a command-line parameter. */
6:
7: #include <stdlib.h>
8: #include <stdio.h>
CH 19 9: #include <time.h>
CH 18 10: #include <string.h>
11:
12: /*** defined constants ***/
13: #define YES 1
14: #define NO 0
15: #define REC_LENGTH 54
16:
17: /*** variables ***/
18:
19: struct record {
20: char fname[15+1]; /* first name + NULL */
21: char lname[20+1]; /* last name + NULL */
22: char mname[10+1]; /* middle name + NULL */
23: char phone[9+1]; /* phone number + NULL */
24: } rec;
25:
26: /*** function prototypes ***/
27:
CH 21 28: int main(int argc, ch ar *argv[]);
29: void display_usage(char *filename);
30: int display_menu(void);
31: void get_data(FILE *fp, char *progname, char *filename);
32: void display_report(FILE *fp);
33: int continue_function(void);
34: int look_up( FILE *fp );
35:
36: /* start of program */
37:
CH 21 38: int main(int argc, ch ar *argv[])
39: {
CH 16 40: FILE *fp;
41: int cont = YES;
42:

The numbers to the left of the line numbers indicate the day that covers the
concept presented on that line. If you’re confused by the line, refer to the
referenced day for more information.

Note


34 448201x-W3R 8/13/02 11:22 AM Page 620

Free download pdf