int _tmain(int argc, _TCHAR* argv[])
{
char n;
CString strTime; // 用於將CTime對象格式化為字符串
CTime curTime = CTime::GetCurrentTime();
cout<<GetExePath()<<endl;
/*cout<<"請輸入要刪除幾天前的文件夾:";
cin>>n;
*/
cout<<argv[1]<<endl;
n=_ttoi(argv[1]);
// cout<<n<<endl;
CTime t=curTime-CTimeSpan(n,0,0,0);
strTime = t.Format(_T("db%Y%m%d*"));
//wcout<<(LPCTSTR)strTime<<endl;
CString m=strTime;
strcpy_s(s,256,GetExePath());
cout<<s<<endl;
strcat_s(s,256,m);
cout<<s<<endl;
transfer(s);
return 0;
1>shijianbijiao1.cpp(197): error C2664: 'strcpy_s' : cannot convert parameter 3 from 'CString' to 'const char *'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>shijianbijiao1.cpp(200): error C2664: 'strcat_s' : cannot convert parameter 3 from 'CString' to 'const char *'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>
CString是Unicode編碼,strcpy_s要求參數是char*,所以你需要先把CString類型轉換為char類型
用CW2A
strcat_s(s,256,CW2A(m));