比较复杂的也有想到 可是真的太复杂 结构体中每个变量都要计算 那有没有什么简便的方法呢?
拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...
You can only build struct or class yourself. You can search to see if there are any third-party libraries. Unlike Java, there are richer Date types.
struct
class
Java
Date
Are you talking about mktime?
#include <stdio.h> #include <time.h> int main(void) { struct tm tm = *localtime(&(time_t){time(NULL)}); printf("Today is %s", asctime(&tm)); tm.tm_mon -= 100; mktime(&tm); printf("100 months ago was %s", asctime(&tm)); }
Output:
Today is Sun Oct 4 19:11:45 2015100 months ago was Mon Jun 4 19:11:45 2007
You can only build
struct
orclass
yourself. You can search to see if there are any third-party libraries. UnlikeJava
, there are richerDate
types.Are you talking about mktime?
Output: