游戏开发论坛

 找回密码
 立即注册
搜索
查看: 3171|回复: 2

格式串摸板

[复制链接]

38

主题

96

帖子

148

积分

注册会员

Rank: 2

积分
148
发表于 2004-6-26 15:25:00 | 显示全部楼层 |阅读模式
//代码名称:  格式串摸板
//类别:      格式字符串
//关健字:    格式化 字符串
//作者:      EasySL
//编译器:    VC
//操作系统:  windows

// 格式串垫片函数模版
template <const int iBufLen> inline const char *FormatString( LPCTSTR szFormat, ... )
{
    static char szOutStr[iBufLen];
    szOutStr[0] = 0;
        va_list vl;

    va_start( vl, szFormat );
    vsprintf(szOutStr, szFormat, vl);
    va_end(vl);

    return szOutStr;
}
#define FSTR FormatString<1024>

// 格式串垫片类模版
template <const int iBufLen>
class CFormatString
{
public:
    CFormatString( LPCTSTR szFormat, ... )
    {
        m_szOutStr[0] = 0;
        va_list vl;

        va_start( vl, szFormat );
        vsprintf( m_szOutStr, szFormat, vl );
        va_end( vl );
    }
    operator const char *() const { return m_szOutStr; }
private:
    char m_szOutStr[iBufLen];
};
#define CFSTR CFormatString<1024>

3

主题

155

帖子

161

积分

注册会员

Rank: 2

积分
161
发表于 2004-7-6 14:16:00 | 显示全部楼层

Re:格式串摸板

sdm~~~~~~~~~~~~~

11

主题

188

帖子

194

积分

注册会员

Rank: 2

积分
194
发表于 2004-9-24 22:49:00 | 显示全部楼层

Re:格式串摸板

??
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-8-18 19:01

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表