输出时间

/*    打印每次读取的时间                                                                  */

        ofstream outFile;
        outFile.open("test.log", ios_base::app);
        if (!outFile.is_open())//
        {
            cout << "open OUTPUT file error";
            cout << "program terminating.
";

        }
        CTime tm = CTime::GetCurrentTime();
        CString str = tm.Format("%Y-%m-%d-%X");
        char *cssst = (char *)(str.GetBuffer(str.GetLength() + 1));
        //MessageBox(str, NULL, MB_OK);
        for (int i = 0; i < 2 * str.GetLength(); i++)
        {            
            outFile << *(cssst + i);
        }
        outFile << endl;    

Cstring转成char*以后在outfile输出的时候不能用outFile<<cssst<<endl;表示无奈只能for循环一个内存一个内存的输出

原文地址:https://www.cnblogs.com/xifengib/p/5897137.html