va_list 传递函数变参到下一个函数的使用方法:
来源:互联网 发布:数据采集协议 编辑:程序博客网 时间:2024/06/06 23:16
#include<stdio.h>
#include<stdarg.h>
#include <memory.h>
void fun2(int start,va_list ap);
void simple_va_fun(int start,...)
{
va_list arg_ptr;
int nArgValue = start;
int nArgCount = 0;
va_start(arg_ptr,start);
fun2(start,arg_ptr);
va_end(arg_ptr);
return;
}
void fun2(int start,va_list ap)
{
int nArgValue = start;
int nArgCount = 0;
do
{
++nArgCount;
printf("the %d the arg:%d/n",nArgCount,nArgValue);
nArgValue = va_arg(ap,int);
}
while (nArgValue != -1);
}
main()
{
simple_va_fun(100,200,-1);
simple_va_fun(777,888,999,67567,45678,3245,-1);
}
以上代码在fedora13下运行通过:
zxr@localhost/mnt/hgfs/linuxtmp/src/tstVa_list$./a.out
the 1 the arg:100
the 2 the arg:200
the 1 the arg:777
the 2 the arg:888
the 3 the arg:999
the 4 the arg:67567
the 5 the arg:45678
the 6 the arg:3245
zxr@localhost/mnt/hgfs/linuxtmp/src/tstVa_list$
- va_list 传递函数变参到下一个函数的使用方法:
- va_list使用方法
- addObserver和postNotification函数传递函数的区别
- va_list、va_start、va_arg、va_end宏的使用方法
- VC:va_list用法---隐含参数的使用方法
- va_list可变参数的函数
- linux下一个定时器的使用方法
- 函数可变参数va_list、va_start、va_arg、va_end原理及使用方法
- 变参数print函数的实现va_list
- 传递函数
- va_list va_start va_arg va_end 使用方法
- 数据库,部分函数依赖,传递函数依赖,完全函数依赖,三种范式的区别
- va_list函数族应用
- 有关VA_LIST的用法--变参函数的实现
- 有关VA_LIST的用法--变参函数的实现
- 有关va_list和vsnprintf输出函数的问题
- 有关va_list和vsnprintf输出函数的问题
- 关于C中函数的可变参数va_list...
- bo cognos ssrs等报表工具使用比较
- MTK NVRAM 总结
- GridView与DetailsView控件联用实例代码
- 异常
- idtcpserver和idtcpclient传二进制文件用流
- va_list 传递函数变参到下一个函数的使用方法:
- java字符串编码类型获取
- char、varchar、bigint、int等的区别及数据库的数据 类型
- undefined reference to `__gxx_personality_v0' collect2: ld returned 1 exit status
- "数组引用"以避免"数组降阶"(c++)
- 忙的有点迷茫了
- 右键菜单添加UltraEdit的选项(转)
- 自动化测试的7个步骤:支持产品的可测试性
- 右键菜单添加UltraEdit的选项(转)