va_list passthrough [英] va_list passthrough

查看:85
本文介绍了va_list passthrough的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法将一个变量列表传递给一个函数,以便作为一个passthrough行动




例如:


void new_printf(char * buf,...)

{

va_list vlist;


<稍微修改buf>


printf(buf,vlist);

}

Is there any way to pass a variable list to a function, so as to act
as a passthrough?

for example:

void new_printf ( char *buf , ... )
{
va_list vlist;

<modify buf slightly>

printf( buf , vlist );
}

推荐答案

raphfrk写道:
raphfrk wrote:

有没有办法将变量列表传递给函数,以便行动

作为passthrough?


例如:


void new_printf(char * buf,...)

{

va_list vlist;


<稍微修改buf>


printf(buf,vlist);

}
Is there any way to pass a variable list to a function, so as to act
as a passthrough?

for example:

void new_printf ( char *buf , ... )
{
va_list vlist;

<modify buf slightly>

printf( buf , vlist );
}



使用va_copy。

Use va_copy.


7月7日,上午11:03,santosh< santosh .... @ gmail.comwrote:
On Jul 7, 11:03 am, santosh <santosh....@gmail.comwrote:

raphfrk写道:
raphfrk wrote:

有没有办法将变量列表传递给函数,以便将
作为直通?
Is there any way to pass a variable list to a function, so as to act
as a passthrough?


例如:
for example:


void new_printf(char * buf, ...)

{

va_list vlist;
void new_printf ( char *buf , ... )
{
va_list vlist;


<稍微修改buf>
<modify buf slightly>


printf(buf,vlist);

}
printf( buf , vlist );
}



使用va_copy。


Use va_copy.



我不认为这就是我想要的。


我想要一个允许类似于以下是

的工作。


#include< stdio.h>


int main()

{


int a = 7l;


new_printf("%d \ n",a);


返回0;

}


void new_printf(char * buf,...)

{


printf(buf,...); // va列表传递给printf


}


上面的效果是new_printf与

printf。


I don''t think that is what I want.

I want a program that would allow something like the following to
work.

#include <stdio.h>

int main()
{

int a=7l;

new_printf("%d\n" , a );

return 0;
}

void new_printf ( char *buf , ... )
{

printf( buf , ... ); // the va list is passed to printf

}

The effect of the above would be that new_printf acts the same as
printf.


7月7日3:01 * pm,raphfrk< raph ... @netscape.netwrote:
On Jul 7, 3:01*pm, raphfrk <raph...@netscape.netwrote:

有没有办法将变量列表传递给函数,以便将
作为直通行为?


例如:


void new_printf(char * buf,...)

{

* va_list vlist;


*<稍微修改buf>


* printf(buf,vlist);


}

Is there any way to pass a variable list to a function, so as to act
as a passthrough?

for example:

void new_printf ( char *buf , ... )
{
* va_list vlist;

* <modify buf slightly>

* printf( buf , vlist );

}



使用va_copy。

#include< stdarg.h>

void va_copy( va_list dest,va_list src);


原型是自解释的。您打算如何修改va_list?

Use va_copy.
#include <stdarg.h>
void va_copy(va_list dest, va_list src);

The prototype is self explanatory. How do you plan to modify va_list?


这篇关于va_list passthrough的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆