Programming-in-C
Programming-in-C copied to clipboard
chapter08/ex4.c
Line 25 structure definition is incorrect, size of the tab of char should be day[10] and not day[9].
Try to enter the date 01 05 2024, the answer will be wednesdaythursday instead of wednesday.
That's because the '\0' is missing due to the wrong size definition, therefore the printf function looks for the '\0' of thursday which is next to wednesday in memory.
24 struct WeekDays { 25 char day[9]; 26 };