c-如何保存当前日期以用于将来的记录



此代码正在打印当前日期,但我想将其保存以备将来记录,如该日期的存款金额。如何做到这一点,以及如何以一种可以与其他功能一起使用的方式保存它?

#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main(void)
{
time_t now = time(NULL);
struct tm *t = localtime(&now);
printf( "%d-", t->tm_mon+1 );
printf( "%d-", t->tm_mday );
printf( "%dn", t->tm_year+1900 );
return 0;
}

使用一个文件并通过fprintf((打印到该文件中。

最新更新