Format() 函数用于将数据转换为格式化的字符串输出
2014-12-04 14:53
441 查看
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
举例如下;
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
相关文章推荐
- String.format() / 字符串拼接格式化输出数据
- 神一般的 str.format() 函数 - Python 字符串格式化转换(转载)
- symbian 字符串描述符格式化format输出转换
- 将整形数据转换为反转数字字符串输出
- vb6的一些自己写的函数 用于类型转换,十六进制输出,字节转换
- Oracle常用函数(字符串、数据类型转换、日期类型)
- 格式化数据输出_string.Format
- SQL自定义函数实现字符串截取转化为整型(主要用于对批量数据的操作)
- 输入一个表示整数的字符串,把该字符串转换成整数并输出(实现atoi函数功能)
- 编写函数,其功能是:将一个数字字符串转换为一个整数(不得调用C语言中提供的将字符串转换成整数的函数。)要求在主函数中输入该字符串并输出转换后的整数的值。
- scanf和printf函数家族用于格式化输入和输出(转)
- Delphi格式化输出函数(1): Format
- 各种格式化文件大小为字符串的函数FormatFileSize
- 字符串转换为整型数据输出例子
- FormatRemoteUrl函数之asp实现格式化成当前网站完整的URL-将相对地址转换为绝对地址的代码
- MessageFormat对象实现格式化字符串输出,类似C#中的string.format方法
- 格式化输出函数(1): Format
- 函数用于把一个用逗号分隔的多个数据字符串变成一个表的一列
- python输出格式化及函数format
- MessageFormat对象实现格式化字符串输出,类似C#中的string.format方法