_ASSERTE(_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)); ╰半夏微凉° 2022-01-29 06:43 193阅读 0赞 一个容易被忽视的地方,引发了标题所属的错误!详见代码: #include "stdafx.h" #include <time.h> #include <string> // std::string time2string() { time_t t = time(NULL); char buf[32]; int size = sizeof(buf);//32 strftime(buf, size, "%Y-%m-%d %H:%M:%S", localtime(&t)); return buf; } // std::wstring time2wstring() { time_t t = time(NULL); wchar_t buf[64]; int size = sizeof(buf);//128 wcsftime(buf, size, L"%Y-%m-%d %H:%M:%S", localtime(&t));//引发错误 return buf; } // int _tmain(int argc, _TCHAR* argv[]) { std::wstring wsztime = time2wstring(); wprintf(L"wsztime : %s\n", wsztime.c_str()); std::string sztime = time2string(); printf("sztime : %s\n", sztime.c_str()); system("pause"); return 0; }
还没有评论,来说两句吧...