CString,string,char*的綜合比較(二)

來源:互聯網
上載者:User

接上一篇。。。

e) 增加

作用 char* string CString
動態增加值 strcat push

append

Append

AppendChar

AppendFormat


f) 截取

作用 char* string CString
得到部分值 用下標操作 substr Left

Mid

Right

Truncate


g) 移除

作用 char* string CString
移除部份值   remove Remove
移除空白值 RemoveBlanks

註:此為ATL提供,非C函數

remove_if Trim

TrimLeft

TrimRig


h) 轉換大小寫

作用 char* string CString
轉換大小寫 _strlwr

_strupr

  MakeLower

MakeUpper


i) 與其他類型轉換

作用 char* string CString
轉化為數字 atoi

atod

atof

  Format
轉化為char*   c_str
GetBuffer

GetBufferSetLen

j) 格式化

作用 char* string CString
格式化 sprintf   Format


k) 得到長度

作用 char* string CString
得到長度 strlen length GetLength
得到大小   size GetAllocLength

l) 判斷為空白

作用 char* string CString
判斷是否為空白 判斷是否==NULL或者第一個字元是否是’\0’ empty IsEmpty

m) 重定義大小

作用 char* string CString
重定義大小 realloc

new
resize GetBufferSetLength

n) 釋放資源

作用 char* string CString
釋放 free

delete (delete[])

  ReleaseBuffer

ReleaseBufferSetLength

(五) 安全性>

CString > string > char*;

(六) 靈活性

CString > string >char*;

(七) 可移植性

char* = string > CString

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.