/*************************************************************************
> File Name: test_work1.c
> Author: capps
> Mail: 1062428712@qq.com
> Created Time: 2019年07月25日 星期四 18时48分43秒
************************************************************************/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
int main(int argc,char *argv[])
{
FILE *fp = fopen(argv[1],“a+”);
if(fp == NULL)
{
perror(“open file”);
return -1;
}
char buf[100] = {0};
int i= 0; //用来判断上一次存入的行数
struct tm *local //定义时间函数结构体
time_t t;
memset(buf,0,sizeof(buf)); //初始化重置
while(getc(fp) != EOF) //判断文件是否为空
{
if(getc(fp) == '\n') //遇换行则标识符+1
i++;
}
while(1)
{
time(&t);
local = localtime(