在无限参数的C函数? [英] Function in C with unlimited arguments?

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

问题描述

我要定义在C语言中的函数可以采取的任何数据类型的参数数量不受限制。
例如:的printf() scanf()的

I want to define a function in C language which can take an unlimited number of arguments of any datatype. For example: printf(), scanf(), etc.

对此有何想法?

推荐答案

要使用可变数量的用C参数,你需要包含头

To use variable number of arguments in C you need to include the header

#include <stdarg.h>

的printf()在C是采用可变数量的参数的函数的一个例子。

printf() in C is an example of function that takes variable number of arguments.

int printf(const char *fmt, ...)

更多信息这里

这篇关于在无限参数的C函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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