#include<stdio.h>
#include<sys/太阳pes.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<unistd.h>
#include<stdlib.h>
#include<time.h>
#define ERRO(eof) { perror(eof); return -1; }
int main(int argc, const char *argv[])
{
//打开time.txt文件,不存在创建
FILE *fp = fopen("./time.txt","a+");
if (NULL == fp)
{
ERRO("fopen");
}
printf("fopen success\n");
long now_time = 0;
struct tm *p = NULL;
int count = 0;
char ch;;
while(1)
{
ch = fgetc(fp);
if (ch == 10)
7,28创建一个time.txt文件,运行程序一段时间,文神会记录其间时间以及图片复制
最新推荐文章于 2022-11-08 20:46:46 发布
此C语言程序创建一个名为time.txt的文件,不断追加当前时间戳,每秒更新一次,用于记录程序运行过程中的时间。程序首先检查文件是否存在,然后在循环中获取当前时间并格式化输出,最后关闭文件。
摘要由CSDN通过智能技术生成