Programming-in-C icon indicating copy to clipboard operation
Programming-in-C copied to clipboard

chapter08/ex4.c

Open Richard3134 opened this issue 1 year ago • 0 comments

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 };

Richard3134 avatar Apr 26 '24 13:04 Richard3134