Format() 函数用于将数据转换为格式化的字符串输出
举例如下;
int x = 123;
CString str;
str.Format("%d", x); // 123
str.Format("%6d", x); // 123
str.Format("%06d", x); //000123 ....不够6位 前面补0 这个比较实用
str.Format("%x", x); //7b
str.Format("%X", x); //7B
str.Format("%04x", x); //007b
float x = 123.456;
str.Format("%f", x); // 123.456
str.Format("%2.3f"); // 123.456
str.Format("%4.2f"); // 123.45
本文详细介绍了Format()函数的使用方法及格式化字符串输出的各种应用场景,包括整数、浮点数等不同类型的数据格式化技巧。
2097

被折叠的 条评论
为什么被折叠?



