ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Is there anyway to make a function prototype to take multible parameters. I'm trying to make an alternative printf, that besides formating the content, always displays the PID
e.g.
syntax
Code:
...
printj("\nHello %s. Current date is %d.", name, date);
output:
...
PID: 17966 - Hello Jay. Current date is 121304
But it must not be limited to 2 arguments. It should also take 0 or 50 arguments.
Any infomation will be greatly appriciated.
DESCRIPTION
This set of macros allows portable procedures that accept
variable numbers of arguments of variable types to be writ-
ten. Routines that have variable argument lists (such as
printf) but do not use stdarg are inherently non-portable,
as different machines use different argument-passing conven-
tions.
va_list is a type defined for the variable used to traverse
the list.
The va_start() macro is invoked before any access to the
unnamed arguments and initializes pvar for subsequent use by
va_arg() and va_end(). The parameter parmN is the identifier
of the rightmost parameter in the variable parameter list in
the function definition (the one just before the , ...). If
this parameter is declared with the register storage class
or with a function or array type, or with a type that is not
compatible with the type that results after application of
the default argument promotions, the behavior is undefined.
The parameter parmN is required under strict ANSI C compila-
tion. In other compilation modes, parmN need not be supplied
and the second parameter to the va_start() macro can be left
empty (for example, va_start(pvar, ). This allows for rou-
tines that contain no parameters before the ... in the vari-
able parameter list.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.