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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

CString::Format

發布時間:2025/3/15 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CString::Format 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

CString::Format

//?看代碼,針對format帶參數列表的情況沒整明白,于是開始百度,搜索百度一大圈沒找到好的解答,最后還是微軟靠譜,與大家分享。

voidFormat(LPCTSTRlpszFormat**, ...);**

void Format( UINT?nFormatID**, ... );**

Parameters

lpszFormat

A format-control string.

nFormatID

The string resource identifier that contains the format-control string.

Remarks

Call this member function to write formatted data to a?CString?in the same way that?sprintf?formats data into a C-style character array. This function formats and stores a series of characters and values in the?CString. Each optional argument (if any) is converted and output according to the corresponding format specification in?lpszFormat?or from the string resource identified by?nFormatID.

The call will fail if the string object itself is offered as a parameter to?Format. For example, the following code:

CString str = "Some Data"; str.Format("%s%d", str, 123);?? // Attention: str is also used in the parameter list.

will cause unpredictable results.

When you pass a character string as an optional argument, you?must?cast it explicitly as?LPCTSTR. The format has the same form and function as the format argument for the?printf?function. (For a description of the format and arguments, see?in the?Run-Time Library Reference.) A null character is appended to the end of the characters written.

For more information, see?in the?Run-Time Library Reference.

Example

CString str;str.Format(_T("Floating point: %.2f\n"), 12345.12345); _tprintf("%s", (LPCTSTR) str);str.Format(_T("Left-justified integer: %.6d\n"), 35); _tprintf("%s", (LPCTSTR) str);str.Format(IDS_SCORE, 5, 3); _tprintf("%s", (LPCTSTR) str);

Output

If the application has a string resource with the identifier IDS_SCORE that contains the string "Penguins: %d\nFlyers? : %d\n", the above code fragment produces this output:

Floating point: 12345.12 Left-justified integer: 000035 Penguins: 5 Flyers? : 3

CString Overview?|??Class Members?|??Hierarchy Chart

總結

以上是生活随笔為你收集整理的CString::Format的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。