🦄 refactor(C13, C14, C115): 更新了linux系统开发部分的结构
This commit is contained in:
34
C14-文件系统/100days.c
Normal file
34
C14-文件系统/100days.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#define TIMESTRSIZE 128
|
||||
|
||||
/**
|
||||
* @brief 找出100天以后是哪一天
|
||||
* @details
|
||||
*
|
||||
* @param argc
|
||||
* @param argv
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
time_t stamp;
|
||||
struct tm *tm;
|
||||
char timestr[TIMESTRSIZE];
|
||||
|
||||
time(&stamp);
|
||||
tm = localtime(&stamp);
|
||||
strftime(timestr, TIMESTRSIZE, "Now: %Y-%m-%d", tm);
|
||||
puts(timestr);
|
||||
|
||||
tm->tm_mday += 100;
|
||||
// mktime 会先调整tm溢出的情况
|
||||
mktime(tm);
|
||||
strftime(timestr, TIMESTRSIZE, "100 days later: %Y-%m-%d", tm);
|
||||
puts(timestr);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
Reference in New Issue
Block a user