#include <stdio.h>
#include <time.h>

char *wday[] = {"Sunday", "Monday", "Tuesday", "Wednesday",
                "Thursday", "Friday", "Saturday", "Unknown"};

int main(void)
{
  struct tm time_check;
  int year, month, day;

/*jahr,monat und tag eingeben zum herausfinden des Wochentags*/
  printf("Year: ");
  scanf("%d", &year);
  printf("Month: ");
  scanf("%d", &month);
  printf("Day: ");
  scanf("%d", &day);

/*Wir füllen unsere Struktur struct tm time_check mit Werten*/
  time_check.tm_year = year - 1900;
  time_check.tm_mon = month - 1;
  time_check.tm_mday = day;


/* 00:00:01 Uhr*/
  time_check.tm_hour = 0;
  time_check.tm_min = 0;
  time_check.tm_sec = 1;
  time_check.tm_isdst = -1;

/* call mktime to fill in the weekday field of the structure */
  if (mktime(&time_check) == -1)
      time_check.tm_wday = 7;  /*==Unbekannter Tag*/

/* Der Tag des Datums wird ausgegeben */
  printf("That day is a %s\n", wday[time_check.tm_wday]);
  return 0;
}
