VC 类型转换问题

来源:百度知道 编辑:UC知道 时间:2024/09/24 22:23:38
要把一个CString 类型的变量,赋给一个CTime类型的变量,怎么做呢??
强制转换吗??怎么转呢`~

CString timestr = "2000年04月05日";
int a,b,c ;
sscanf(timestr.GetBuffer(timestr.GetLength()),"%d年%d月%d日",&a,&b,&c);
CTime time(a,b,c,0,0,0);

or

CString s("2001-8-29 19:06:23");
int nYear, nMonth, nDate, nHour, nMin, nSec;
sscanf(s, "%d-%d-%d %d:%d:%d", &nYear, &nMonth, &nDate, &nHour, &nMin, &nSec);
CTime t(nYear, nMonth, nDate, nHour, nMin, nSec);