DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Getting Started

Reading the appointments

To read the appointments, we read one line at a time, constructing an Appointment from the information on each line, and inserting each Appointment into the calendar:

       void read_appts(Calendar& cal) {
           char buf[100];
           while (cin.getline(buf,100,'\t')) {
               Appointment a;
               a.time  = make_time(buf);
               cin.getline(buf,100,'\n');
               a.desc = buf;
               cal.add(a);
           }
       }
The first call to getline() reads the characters preceding the first tab, and second call reads the characters from the tab to the newline. Conversion of the first chunk of characters to a Time is made simple by the Time(3C++) function make_time(), which recognizes a wide variety of string representations.

Notice we assume the Calendar type has an operation add() to add an Appointment. Below we will implement this operation, but first we must decide on a representation for the Calendar.


Next topic: Choosing a representation for the Calendar
Previous topic: Start by assembling the obvious components

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004