C program days between two dates

前端 未结 6 444
悲&欢浪女
悲&欢浪女 2021-01-02 18:30

I have written a program that should find the days between two dates, but it has some hiccups. The logic makes perfect sense in my head when I read through it, so

6条回答
  •  滥情空心
    2021-01-02 18:37

    Reduce all month indexes by 1.

    What I mean to say is January will correspond to daysPerMonth[0] or daysPerMonthLeap[0] and not daysPerMonth[1] or daysPerMonthLeap[1]. The reason for this being array indexes start from 0.

    So, wherever you are using month1, month2 insidedaysPerMonth[] or daysPerMonthLeap[], use month1-1 and month2-1 instead.

    I hope this is clear enough. Otherwise, feel free to comment.

提交回复
热议问题