如何创建文件名中包含当前日期的文件?

  FILE * fp;
  char path[100];
  char LogFile[100];
  char tmpDate[30];
  time_t now; 
  struct tm *p; 


  time(&now); 
  p = localtime(&now);


  strftime(tmpDate, 29, "%Y%m%d", p);
  path = "//A//B//C//";
  sprintf (LogFile, "%sd.%s.log"
                  , path
                  , tmpDate);
  if ((fp = fopen(LogFile, "a")) != NULL) { 
    //写入内容
    fflush(fp); 
    fclose(fp);
  }

你可能感兴趣的:(如何创建文件名中包含当前日期的文件?)