C program days between two dates

前端 未结 6 429
悲&欢浪女
悲&欢浪女 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:49

    This is not a complete answer. I just wanted to mention a better way to calculate leap year (this is taken from The C Programming Language - Page #41)

    if ((year % 4 == 0 && year % 100 != 0) || year % 400 ==0)
        printf("%d is a leap year \n", year);
    else
        printf("%d is not a leap year \n", year);
    

提交回复
热议问题