国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
C++日期時間與字符串間的轉(zhuǎn)換 — Windows Live
 
2月21日

C++日期時間與字符串間的轉(zhuǎn)換

VC6

CString sTime = _T("2007-10-26 13:20:30"); 

char *charTime = (LPSTR)(LPCTSTR)sTime;

CString sFormat = _T("%d-%d-%d %d:%d:%d");

char *charFormat = (LPSTR)(LPCTSTR)sFormat;

int nYear;

int nMonth;

int nDate;

int nHour;

int nMin;

int nSec; 

stscanf(charTime,charFormat,&nYear,&nMonth,&nDate,&nHour,&nMin,&nSec);

CTime t(nYear,nMonth,nDate,nHour,nMin,nSec);

CString s = t.Format(_T("%Y%m%d%H%M%S"));

VC2005

不含中文格式

stscanf(charTime,charFormat,&nYear,&nMonth,&nDate,&nHour,&nMin,&nSec); 

CString sTime = _T("2007-10-26 12:40:10"); 

TCHAR *charTime = (TCHAR*)(LPCTSTR)sTime;

CString sFormat = _T("%d-%d-%d %d:%d:%d");

TCHAR *charFormat = (TCHAR*)(LPCTSTR)sFormat;

int nYear;

int nMonth;

int nDate;

int nHour;

int nMin;

int nSec; 

_stscanf(charTime,charFormat,&nYear,&nMonth,&nDate,&nHour,&nMin,&nSec);

CTime t(nYear,nMonth,nDate,nHour,nMin,nSec);

CString s = t.Format(_T("%Y-%m-%d %H:%M:%S"));

含中文格式

要包含#include <locale.h>

CString sTime = _T("2007-10-26 12:40:10"); 

TCHAR *charTime = (TCHAR*)(LPCTSTR)sTime;

CString sFormat = _T("%d-%d-%d %d:%d:%d");

TCHAR *charFormat = (TCHAR*)(LPCTSTR)sFormat;

int nYear;

int nMonth;

int nDate;

int nHour;

int nMin;

int nSec; 

_stscanf(charTime,charFormat,&nYear,&nMonth,&nDate,&nHour,&nMin,&nSec);  

CTime t(nYear,nMonth,nDate,nHour,nMin,nSec);

_tsetlocale(LC_ALL,_T("Chinese-simplified")); //本地化

CString s = t.Format(_T("%Y%m%d%H%M%S"));

本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
用CTime類得到當(dāng)前日期、時間、星期,并格式化輸出
COleDateTime和CTime類型的應(yīng)用
如何在網(wǎng)頁中顯示服務(wù)器時間
VS2010/MFC編程入門之四十三(MFC常用類:CTime類和CTimeSpan類)
校驗身份證號碼有效性的代碼
C 的多態(tài)性(一)
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服