Advertisement
stream13

dated filename

Nov 28th, 2012
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <time.h>
  2. #include <stdio.h>
  3.  
  4. using namespace std;
  5.  
  6. int main(){
  7.     time_t t = time(NULL);
  8.     struct tm tm = *localtime(&t);
  9.     char filename[50] = {0};
  10.  
  11.     sprintf(filename, "filename_%d.%d.%d_%d-%d-%d.log", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
  12.     FILE *pFile;
  13.  
  14.     pFile = fopen(filename, "w");
  15.     fprintf(pFile, filename);
  16.    
  17.     fclose(pFile);
  18.  
  19.  
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement