home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / tutorial / cpptutor / source / newdate.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-15  |  597 b   |  26 lines

  1.                               // Chapter 7 - Program 10 - NEWDATE.CPP
  2. #include "newdate.h"
  3.  
  4. extern int days[];
  5.  
  6.          // This routine ignores leap year for simplicity, and adds
  7.          //  the days in each month for all months less than the
  8.          //  current month, then adds the days in the current month
  9.          //  up to today.
  10. int new_date::get_day_of_year(void)
  11. {
  12. int index = 0;
  13.  
  14.    day_of_year = 0;
  15.  
  16.    while (index < month)
  17.       day_of_year += days[index++];
  18.  
  19.    return (day_of_year += day);
  20. }
  21.  
  22.  
  23. // Result of execution
  24. //
  25. // (This file cannot be executed)
  26.