Tilbage til slide -- Tastaturgenvej: 'u'                      dates.c - Et dato program med en funktion, date-before, der vurderer om en dato kommer før en anden dato.Lektion 9 - slide 10 : 29
Program 1

#include <stdio.h>

enum weekday {sunday, monday, tuesday, wednesday, thursday, 
              friday, saturday};
typedef enum weekday weekday;

struct date {
  weekday day_of_week;
  int day;
  int month;
  int year;
};

typedef struct date date;

/* Is date d1 less than date d2 */
int date_before(date d1, date d2){
 return
  (d1.year < d2.year) ||
  (d1.year == d2.year && d1.month < d2.month) ||
  (d1.year == d2.year && d1.month == d2.month && d1.day < d2.day);
}  

int main(void) {

  date today = {thursday, 14, 4, 2005};
  date tomorrow = {friday, 15, 4, 2005};

  if (date_before(today, tomorrow))
    printf("OK\n");
  else printf("Problems\n");

  return 0;
}