< previous page page_96 next page >

Page 96
(continued)
Listing 5.8
#include <stdio.h>


char *day_of_week_name (int day_index)
{
   char *DOW_table [7] = {"Sunday", "Monday", "Tuesday", "Wednesday",
                          "Thursday", "Friday", "Saturday"
                         };


   if ((day_index < 0) || (day_index > 6))
      return (NULL);


   return (DOW_table [day_index]);
}

Listing 5.9 day_of_week_abbreviation()
/* dowabbr.c
   +-------------------------------------------+
   |   Copyright (C) 1995 by Lance W. Latham.  |
   |         All rights reserved.              |
   +-------------------------------------------+


   Returns a standard three-character abbreviation for the name of
   the day of the week for a given numeric index.


   INPUTS:
   1. day_index, type int, an integer value coding the day of the week,
      as follows:
        0 = Sunday
        1 = Monday
        2 = Tuesday
        3 = Wednesday
        4 = Thursday
        5 = Friday
        6 = Saturday


   OUTPUTS:
   1. Returned by routine, string, containing a three-letter abbreviation
      of the name of the day of the week which corresponds to the input
      index, as follows:


        0 = Sun
        1 = Mon

 
< previous page page_96 next page >