c++ 获取系统时间 写txt string 转 char* 文件改名 文件删除

 

获取系统时间:

#include <windows.h>
    SYSTEMTIME systm;
    GetLocalTime(&systm);
    char time[64] = { 0 };
    printf("%d %d %d %d %d %d %d", systm.wYear, systm.wMonth, systm.wDay, systm.wHour, systm.wMinute, systm.wSecond, systm.wMilliseconds);

    printf(" %d", systm.wDayOfWeek);    

 

 

写txt:

#include <fstream>
    ofstream fout(outputPass, ios::_Noreplace);
        fout << "# Station name : " << name << endl;
        fout.close();

 

string 2 char* :

            char* matrixpath = (char*)malloc(sizeof(char) * 100);
            strcpy(matrixpath, (outputPass + "TranslationMatrix.txt").c_str());

 

rename:

rename(origin_path, new_path);

 

remove:

remove(path);

 

posted @ 2021-12-07 10:44  WTSRUVF  阅读(58)  评论(0编辑  收藏  举报