MFC->整型、浮點型轉字串(Format函式)
阿新 • • 發佈:2019-01-31
在MFC程式中,CString既可以處理Unicode標準的字串,也可以處理ANSI標準的字串。
FormatVC各種字串轉換用於轉換的格式字元
%c 單個字元
%d 十進位制整數(int)
%ld 十進位制整數(long)
%f 十進位制浮點數(float)
%lf 十進位制浮點數(double)
%o 八進位制數
%s 字串
%u 無符號十進位制數
%x 十六進位制數
使用方法
1、int轉換為CString 字串轉int<pre name="code" class="cpp">int num = 9;
str.Format(_T(%4d), num);
2、十進位制轉八進位制
int num = 9;
str.Format(_T(%o), num);