天下

记录修行的印记

可变参数

#include <stdio.h>
#include <stdarg.h>

static CString xGetUpdateParam(const Json::Value& jo,int count,)
{
    string strValue;
    CString strParam(" ");
    va_list arg_list; 
    va_start(arg_list,count); 
    for(int i=0; i<count; i++)
    {
        const char* pszKey = va_arg(arg_list, const char*);
        strValue = jo[pszKey].asString();
        if (!strValue.empty())
        {
            strParam.AppendFormat("%s='%s',",pszKey,strValue.c_str());
        }
        //int nRet = vfprintf(stdout,str,arg_list);
    }
    va_end(arg_list); 
    strParam = strParam.Left(strParam.GetLength()-1);
    return strParam;
}



int myPrint(char *str,)
{
    va_list arg_list; 
    va_start(arg_list,str); 
    int nRet = vfprintf(stdout,str,arg_list);
    va_end(arg_list); 
    return nRet;

int main() 
{
    int nRet = myPrint("Line:%d\n",__LINE__);
    return 0;
}

posted on 2011-08-07 16:25 天下 阅读(446) 评论(0)  编辑 收藏 引用 所属分类: C/C++


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2013年11月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

导航

统计

常用链接

留言簿(4)

随笔分类(378)

随笔档案(329)

链接

最新随笔

搜索

最新评论