日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

字符数据类型转换代码

發(fā)布時(shí)間:2024/4/18 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 字符数据类型转换代码 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
《字符數(shù)據(jù)類型轉(zhuǎn)換代碼(全部調(diào)試通過)》 作者:Coderui??????????????????????????????????????????????????????????? 書于:2007-6-12 ------------------------------------------------------------------------
int nSize;
char* bufw;
CString str = "Coderui"; nSize = str.GetLength();
bufw = new char[nSize + 1];
strcpy (bufw, str);//CString轉(zhuǎn)char* delete[] bufw;
------------------------------------------------------------------------
CString str = "Coderui";
char* p;
p = str.GetBuffer(str.GetLength());//CString轉(zhuǎn)char*
------------------------------------------------------------------------
CString str = "Coderui";
unsigned char* p;
p = (unsigned char*)str.GetBuffer(str.GetLength());//CString轉(zhuǎn)unsigned char*
------------------------------------------------------------------------
CString str = "88";
int i = atoi(str);//CString轉(zhuǎn)int
------------------------------------------------------------------------
char* p = "88";
int i = atoi(p);//char*轉(zhuǎn)int
------------------------------------------------------------------------
int i = 88;
CString str;
str.Format("%d", i);//int轉(zhuǎn)CString
------------------------------------------------------------------------
char ch[8] = {0};
CString str = "Coderui";
strncpy(ch, (LPCTSTR)str, sizeof(ch));//CString轉(zhuǎn)char []
------------------------------------------------------------------------
char ch[8] = {"Coderui"};
CString str;
str.Format(ch);//char []轉(zhuǎn)CString
------------------------------------------------------------------------

int Year,Month,Day,Hour,Min,Sec;
CString OnTime = "2007-5-8 09:05:21";
sscanf(OnTime, "%d-%d-%d %d:%d:%d", &Year, &Month, &Day, &Hour, &Min, &Sec);
CTime Time(Year, Month , Day, Hour, Min, Sec);//CString轉(zhuǎn)CTime
------------------------------------------------------------------------

CString OnTime;
CTime Time = GetCurrentTime();
OnTime = Time.Format("%Y-%m-%d %H:%M:%S");//CTime轉(zhuǎn)CString
------------------------------------------------------------------------
CString OnTime;
SYSTEMTIME st; GetLocalTime(&st);
OnTime.Format("%d-%02d-%02d %d:%d:%d", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);//SYSTEMTIME轉(zhuǎn)CString(日期)
------------------------------------------------------------------------
CONST CHAR *pc = "Coderui";
CString str;
PCTSTR pctstr;
LPCTSTR lpctstr;
PCUTSTR pcutstr;
LPCUTSTR lpcutstr;
LPCSTR lpcstr;
PCSTR pcstr; str.Format("%s", pc);//CONST CHAR *轉(zhuǎn)CString
pctstr = pc;//CONST CHAR *轉(zhuǎn)PCTSTR
lpctstr = pc;//CONST CHAR *轉(zhuǎn)LPCTSTR
pcutstr = pc;//CONST CHAR *轉(zhuǎn)PCUTSTR
lpcutstr = pc;//CONST CHAR *轉(zhuǎn)LPCUTSTR
lpcstr = pc;//CONST CHAR *轉(zhuǎn)LPCSTR
pcstr = pc;//CONST CHAR *轉(zhuǎn)PCSTR
------------------------------------------------------------------------
CString str = "Coderui"; CONST CHAR *pc;
PCTSTR pctstr;
LPCTSTR lpctstr;
PCUTSTR pcutstr;
LPCUTSTR lpcutstr; LPCSTR lpcstr;
PCSTR pcstr; pc = str.GetBuffer(str.GetLength());//CString轉(zhuǎn)CONST CHAR *
pctstr = str.GetBuffer(str.GetLength());//CString轉(zhuǎn)PCTSTR
lpctstr = str.GetBuffer(str.GetLength());//CString轉(zhuǎn)LPCTSTR
pcutstr = str.GetBuffer(str.GetLength());//CString轉(zhuǎn)PCUTSTR
lpcutstr = str.GetBuffer(str.GetLength());//CString轉(zhuǎn)LPCUTSTR
lpcstr = str.GetBuffer(str.GetLength());//CString轉(zhuǎn)LPCSTR
pcstr = str.GetBuffer(str.GetLength());//CString轉(zhuǎn)PCSTR
------------------------------------------------------------------------
PCTSTR pctstr = "Coderui";
LPCTSTR lpctstr = "Coderui";
PCUTSTR pcutstr = "Coderui";
LPCUTSTR lpcutstr = "Coderui";
LPCSTR lpcstr = "Coderui";
PCSTR pcstr = "Coderui"; CONST CHAR *pc;
CString str; pc = pctstr;//PCTSTR轉(zhuǎn)CONST CHAR *
pc = lpctstr;//LPCTSTR轉(zhuǎn)CONST CHAR *
pc = pcutstr;//PCUTSTR轉(zhuǎn)CONST CHAR *
pc = lpcutstr;//LPCUTSTR轉(zhuǎn)CONST CHAR *
pc = lpcstr;//LPCSTR轉(zhuǎn)CONST CHAR *
pc = pcstr;//PCSTR轉(zhuǎn)CONST CHAR *
str.Format("%s", pctstr);//PCTSTR轉(zhuǎn)CString
str.Format("%s", lpctstr);//LPCTSTR轉(zhuǎn)CString
str.Format("%s", pcutstr);//PCUTSTR轉(zhuǎn)CString
str.Format("%s", lpcutstr);//LPCUTSTR轉(zhuǎn)CString
str.Format("%s", lpcstr);//LPCSTR轉(zhuǎn)CString
str.Format("%s", pcstr);//PCSTR轉(zhuǎn)CString
------------------------------------------------------------------------

總結(jié)

以上是生活随笔為你收集整理的字符数据类型转换代码的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。