日期比较发现这是更大的用C [英] Date comparison to find which is bigger in C
本文介绍了日期比较发现这是更大的用C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何找到它是用C语言程序更大的日期
I want to know how to find which is bigger date using a c program
好心帮我PLZ ....
kindly help me out plz....
感谢
推荐答案
您可以使用 difftime
功能:
You can use the difftime
function:
#include <time.h>
#include <stdio.h>
int main(void) {
time_t date1, date2;
// initialize date1 and date2...
double seconds = difftime(date1, date2);
if (seconds > 0) {
printf("Date1 > Date2\n");
}
return 0;
}
如果您的日期是键入 time_t的
的没有,你可以使用函数的 mktime
将它们转换。
If your dates are not of type time_t
, you can use the function mktime
to convert them.
这篇关于日期比较发现这是更大的用C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文