作业帮 > 综合 > 作业

C语言如何输入一个(小时:分钟)格式的时间与系统时间比较,得到相差的秒数

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/24 11:26:03
C语言如何输入一个(小时:分钟)格式的时间与系统时间比较,得到相差的秒数
最好有编好的代码
参照msdn中的实例,你尽情的发挥把.
#include
#include
int main( void )
{
struct tm *newTime;
time_t szClock;
// Get time in seconds
time( &szClock );
// Convert time to struct tm form
newTime = localtime( &szClock );
// Print local time as a string.
printf_s( "Current date and time: %s", asctime( newTime ) ); // C4996
// Note: asctime is deprecated; consider using asctime_s instead
}
结果:
Current date and time: Sun Feb 03 11:38:58 2002