Sams Teach Yourself C in 21 Days

(singke) #1
In Review 379

44: int continue_function(void);
CH 14 45: void clear_kb(void);
46:
47: /*---------------------*/
48: /* start of program */
49: /*---------------------*/
50:
51: int main( void )
52: {
CH 12 53: int cont = YES;
54: int ch;
55:
56: while( cont == YES )
57: {
58: printf( “\n”);
59: printf( “\n MENU”);
60: printf( “\n ========\n”);
61: printf( “\n1. Enter names”);
62: printf( “\n2. Print report”);
63: printf( “\n3. Quit”);
64: printf( “\n\nEnter Selection ==> “);
65:
CH 14 66: ch = getchar();
67:
CH 14 68: fflush(stdin); /* remove extra characters from keyboard buffer */
69:
CH 13 70: switch( ch )
71: {
72: case ‘1’: get_data();
73: break;
74: case ‘2’: display_report();
75: break;
76: case ‘3’: printf(“\n\nThank you for using this program!\n”);
77: cont = NO;
78: break;
CH 13 79: default: printf(“\n\nInvalid choice, Please select 1 to 3!”);
80: break;
81: }
82: }
83: return 0;
84: }
85: /*-----------------------------------------------------------*
86: * Function: get_data() *
87: * Purpose: This function gets the data from the user. It *
88: * continues to get data until either 100 people are *
89: * entered, or the user chooses not to continue. *
90: * Returns: nothing *
91: * Notes: This allows 0/0/0 to be entered for birthdates in *
92: * case the user is unsure. It also allows for 31 days *
93: * in each month. *
94: *-----------------------------------------------------------*/

LISTINGR2.1 continued

23 448201x-W2R 8/13/02 11:12 AM Page 379

Free download pdf