匯入 wsprintf用法

2021-08-29 21:45:37 字數 675 閱讀 1272

在c語言中格式化字串可以使用printf,但是在windows程式設計設計中卻行不通了,但是卻有變通的方法,那就是用 wsprintf這個函式 它的格式如下:

wsprintf(緩衝區,格式,要格式化的值);

第乙個引數是字元緩衝區,後面是格式字串,wsprintf不是將格式化結果寫到標準輸出,而是將其寫入緩衝區中,該函式返回該字串的長度。

比如我們想通過messagebox來輸出乙個整形變數的值,可以用以下**實現:

char szbuffer[100];

ing number=100;

wsprintf(szbuffer, 「%d」,number);

messgaebox(null,szbrffer,text(「格式化字串」),0);

這個函式除了將內容格式化輸出到第乙個引數所提供的字串緩衝區以外,其它功能與printf函式相同

wsprintf對應的字串是寬字元型wchar_t,即乙個字元占用2個位元組的記憶體空間.

sprintf對應的字串是字元型別為char,幾乙個字元占用1個位元組的記憶體空間.

sprintf是用於對ascii碼的127個字元進行操作,wsprintf是對unicode的多語言字元進行操作.

如:sprintf(buffer, "ascii");

wsprintf(buffer, l"unicode");

wsprintf函式詳解

來自 wsprintf 函式作用 函式wsprintf 將一系列的字元和數值輸入到緩衝區。輸出緩衝區裡的的值取決於格式說明符 即 如果寫入的是文字,此函式給寫入的文字的末尾追加乙個 0 函式的返回值是寫入的長度,但不包括最後的 0 語法 int wsprintf lptstrlpout,輸出緩衝區,...

vector 用法 資源匯入

向量圖資源 在drawable目錄生成檔案,如下圖 在gradle2.0及以上 android 在gradle 1.5以前 android flag to tell aapt to keep the attribute ids around aaptoptions 以上為 使用 自己使用的時候直接使...

PHPExcel類匯入Excel用法

if post leadexcel true 匯入excel檔案 function uploadfile file,filetempname echo str die explode 函式把字串分割為陣列。strs explode str sql insert into te 1 2 3 4 5 v...