1 Star 0 Fork 0

杨谨徽 / 代码托管

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
argvlist.c 554 Bytes
一键复制 编辑 原始数据 按行查看 历史
杨谨徽 提交于 2023-09-16 08:51 . add argvlist.c.
/* Example of accessing varying param list */
#include <stdio.h>
#include <stdarg.h> // need this for va_list type
//assume:func() is called with m integers, followed by n strings
int func(int m, int n,...)//n=last known param
{
int i;
va_list ap; //define a va_list ap
va_start(ap, n);//start param list from last param n
for(i=0;i<m;i++)
printf("%d",va_arg(ap, int)); //extract int params
for(i=0;i<n;i++)
printf("%s",va_arg(ap, char*)); //extra char* params
va_end(ap);
}
int main()
{
func(3,2,1,2,3,"test","ok");
}
1
https://gitee.com/SHIBATORI/code-hosting.git
git@gitee.com:SHIBATORI/code-hosting.git
SHIBATORI
code-hosting
代码托管
学习

搜索帮助