cstring 操作詳解[外文翻譯].doc
約17頁(yè)DOC格式手機(jī)打開(kāi)展開(kāi)
cstring 操作詳解[外文翻譯],cstring 操作詳解[外文翻譯]包括英文原文和中文翻譯英文:15300字9頁(yè)中文:5700字8頁(yè)cstrings are a useful data type. they greatly simplify a lot of operations in mfc, making it much more conveni...
內(nèi)容介紹
此文檔由會(huì)員 8008008 發(fā)布
CString 操作詳解[外文翻譯]
包括英文原文和中文翻譯
英文:15300字 9頁(yè)
中文: 5700字 8頁(yè)
CStrings are a useful data type. They greatly simplify a lot of operations in MFC, making it much more convenient to do string manipulation. However, there are some special techniques to using CStrings, particularly hard for people coming from a pure-C background to learn. This essay discusses some of these techniques.
Much of what you need to do is pretty straightforward. This is not a complete tutorial on CStrings, but captures the most common basic questions.
CString concatenation
Formatting (including integer-to-CString)
Converting CStrings to integers
Converting between char * to a CString
char * to CString
CString to char * I: Casting to LPCTSTR
CString to char * II: Using GetBuffer
CString to char * III: Interfacing to a control
CString to BSTR
BSTR to CString (New 30-Jan-01)
VARIANT to CString (New 24-Feb-01)
Loading STRINGTABLE resources (New 22-Feb-01)
CStrings and temporary objects
CString efficiency
String Concatenation
One of the very convenient features of CString is the ability to concatenate two strings. For example if we have
CString gray("Gray");
CString cat("Cat");
CString graycat = gray + cat;
is a lot nicer than having to do something like ......
CString 操作詳解
原著:Joseph M. Newcomer
CString 是一種很有用的數(shù)據(jù)類(lèi)型。它們很大程度上簡(jiǎn)化了MFC中的許多操作,使得MFC在做字符串操作的時(shí)候方便了很多。不管怎樣,使用CString有很多特殊的技巧,特別是對(duì)于純C背景下走出來(lái)的程序員來(lái)說(shuō)有點(diǎn)難以學(xué)習(xí)。這篇文章就來(lái)討論這些技巧。
使用CString可以讓你對(duì)字符串的操作更加直截了當(dāng)。這篇文章不是CString的完全手冊(cè),但囊括了大部分常見(jiàn)基本問(wèn)題。
這篇文章包括以下內(nèi)容:
CString 對(duì)象的連接
格式化字符串(包括 int 型轉(zhuǎn)化為 CString )
CString 型轉(zhuǎn)化成 int 型
CString 型和 char* 類(lèi)型的相互轉(zhuǎn)化
char* 轉(zhuǎn)化成 CString
CString 轉(zhuǎn)化成 char* 之一:使用LPCTSTR強(qiáng)制轉(zhuǎn)化
CString 轉(zhuǎn)化成 char* 之二:使用CString對(duì)象的GetBuffer方法
CString 轉(zhuǎn)化成 char* 之三: 和控件的接口
載入字符串表資源;
CString 和臨時(shí)對(duì)象;
CString 的效率;
總結(jié)
下面我分別討論。
1、CString 對(duì)象的連接
能體現(xiàn)出 CString 類(lèi)型方便性特點(diǎn)的一個(gè)方面就字符串的連接,使用 CString 類(lèi)型,你能很方便地連接兩個(gè)字符串,正如下面的例子:
CString gray("Gray");
CString cat("Cat");
CString graycat = gray + cat;
要比用下面的方法好得多:
char gray[] = "Gray";
char cat[] = "Cat";
char * graycat = malloc(strlen(gray) + strlen(cat) + 1);
strcpy(graycat, gray);
strcat(graycat, cat) ......
包括英文原文和中文翻譯
英文:15300字 9頁(yè)
中文: 5700字 8頁(yè)
CStrings are a useful data type. They greatly simplify a lot of operations in MFC, making it much more convenient to do string manipulation. However, there are some special techniques to using CStrings, particularly hard for people coming from a pure-C background to learn. This essay discusses some of these techniques.
Much of what you need to do is pretty straightforward. This is not a complete tutorial on CStrings, but captures the most common basic questions.
CString concatenation
Formatting (including integer-to-CString)
Converting CStrings to integers
Converting between char * to a CString
char * to CString
CString to char * I: Casting to LPCTSTR
CString to char * II: Using GetBuffer
CString to char * III: Interfacing to a control
CString to BSTR
BSTR to CString (New 30-Jan-01)
VARIANT to CString (New 24-Feb-01)
Loading STRINGTABLE resources (New 22-Feb-01)
CStrings and temporary objects
CString efficiency
String Concatenation
One of the very convenient features of CString is the ability to concatenate two strings. For example if we have
CString gray("Gray");
CString cat("Cat");
CString graycat = gray + cat;
is a lot nicer than having to do something like ......
CString 操作詳解
原著:Joseph M. Newcomer
CString 是一種很有用的數(shù)據(jù)類(lèi)型。它們很大程度上簡(jiǎn)化了MFC中的許多操作,使得MFC在做字符串操作的時(shí)候方便了很多。不管怎樣,使用CString有很多特殊的技巧,特別是對(duì)于純C背景下走出來(lái)的程序員來(lái)說(shuō)有點(diǎn)難以學(xué)習(xí)。這篇文章就來(lái)討論這些技巧。
使用CString可以讓你對(duì)字符串的操作更加直截了當(dāng)。這篇文章不是CString的完全手冊(cè),但囊括了大部分常見(jiàn)基本問(wèn)題。
這篇文章包括以下內(nèi)容:
CString 對(duì)象的連接
格式化字符串(包括 int 型轉(zhuǎn)化為 CString )
CString 型轉(zhuǎn)化成 int 型
CString 型和 char* 類(lèi)型的相互轉(zhuǎn)化
char* 轉(zhuǎn)化成 CString
CString 轉(zhuǎn)化成 char* 之一:使用LPCTSTR強(qiáng)制轉(zhuǎn)化
CString 轉(zhuǎn)化成 char* 之二:使用CString對(duì)象的GetBuffer方法
CString 轉(zhuǎn)化成 char* 之三: 和控件的接口
載入字符串表資源;
CString 和臨時(shí)對(duì)象;
CString 的效率;
總結(jié)
下面我分別討論。
1、CString 對(duì)象的連接
能體現(xiàn)出 CString 類(lèi)型方便性特點(diǎn)的一個(gè)方面就字符串的連接,使用 CString 類(lèi)型,你能很方便地連接兩個(gè)字符串,正如下面的例子:
CString gray("Gray");
CString cat("Cat");
CString graycat = gray + cat;
要比用下面的方法好得多:
char gray[] = "Gray";
char cat[] = "Cat";
char * graycat = malloc(strlen(gray) + strlen(cat) + 1);
strcpy(graycat, gray);
strcat(graycat, cat) ......
TA們正在看...
- 學(xué)士論文-理工科類(lèi)-交通運(yùn)輸對(duì)發(fā)展高速公路客運(yùn)的...pdf
- 學(xué)士論文-社會(huì)文化-論社會(huì)主義新農(nóng)村建設(shè)與警務(wù)工...pdf
- 學(xué)士論文-社會(huì)文化-論道德維度、道德結(jié)構(gòu)和道德價(jià)...pdf
- 學(xué)士論文-經(jīng)濟(jì)學(xué)類(lèi)-關(guān)于消費(fèi)者研究概述.pdf
- 對(duì)行政超越職權(quán)的比較研究.pdf
- 居住權(quán)法律定位探索_民法論文_法律論文.pdf
- 民事審前準(zhǔn)備程序之思考.pdf
- 德國(guó)勞動(dòng)法中的解雇保護(hù)制度.pdf
- 無(wú)因管理不當(dāng)損害的賠償責(zé)任.pdf
- 有權(quán)解釋論質(zhì)疑.pdf