format:自己写的format函数
来源:互联网 发布:macbook专业修图软件 编辑:程序博客网 时间:2024/09/21 09:00
重载自string类,实现额外的Format功能
void Format(const char* szFmt, ...)
{
va_list argList;
va_start(argList, szFmt);
FormatV(szFmt, argList);
va_end(argList);
}
void FormatV(const char* szFormat, va_list argList)
{
char* pBuf = NULL;
int nChars = 1;
int nUsed = 0;
size_type nActual = 0;
int nTry = 0;
do
{
// Grow more than linearly (e.g. 512, 1536, 3072, etc)
nChars += ((nTry+1) * FMT_BLOCK_SIZE);
pBuf = reinterpret_cast<char*>(_alloca(sizeof(char)*nChars));
nUsed = ::_vsnprintf(pBuf, nChars-1, szFormat, argList);
// Ensure proper NULL termination.
nActual = nUsed == -1 ? nChars-1 : Min(nUsed, nChars-1);
pBuf[nActual + 1]= '\0';
}
while ( nUsed < 0 && nTry++ < MAX_FMT_TRIES );
// assign whatever we managed to format
assign(pBuf, nActual);
}
- format:自己写的format函数
- 自己为string写的一个Format函数
- 如何写format函数
- format函数的用法(Delphi)Format
- format函数的使用
- format函数的使用
- 有用的Format函数
- Format函数的用法
- to_char的format 函数
- FORMAT函数的解释
- Format函数的用法
- VBA的Format函数
- python的format函数
- python的format函数
- python的format函数
- python的format函数
- MFC的Format函数
- Format函数
- UIImageview 点击事件
- 使用Cygwin模拟Linux环境安装配置运行基于单机的Hadoop
- 2011年8月份总结
- C#.net Winform获取文件路径
- HTML跳转方法大全
- format:自己写的format函数
- sqlite3 常用操作
- .NET url 的编码与解码
- 实习日记014(0804)
- C语言测试题的讲解分析
- Introduction to PL/SQL
- C# 让程序带参数运行 如:1.exe -a
- 隐式类型转换(C++学习)
- C#读写app.config中的数据