一 最近遇到了一个需要根据时间记录文件名的。先写一个实例来实战:
#include<stdlib.h> #include<time.h> #include<stdio.h> int main() { struct tm *newtime; char outfile[128]; time_t t1; t1 = time(NULL); newtime=localtime(&t1); strftime( outfile, 128, "data_%Y_%m_%H%M%S.bin", newtime); FILE *fp = fopen(outfile, "wd"); fwrite("hello world",1,sizeof("hello world"),fp); fclose(fp); return 0; }
二 这个代码是可以直接用的,有需要的同学可以直接拷贝。
|
作者:虚生 出处:https://www.cnblogs.com/dylancao/ 以音频和传感器算法为核心的智能可穿戴产品解决方案提供商 ,提供可穿戴智能软硬件解决方案的设计,开发和咨询服务。 勾搭热线:邮箱:1173496664@qq.com weixin:18019245820 市场技术对接群:347609188 |
|
浙公网安备 33010602011771号