This question didn't show any activity for more than 21 days. I will ask Community Support to close it unless you finalize it yourself within 7 days.
You can always request to keep this question open. But remember, experts can only help if you provide feedback to their comments.
Unless there is objection or further activity, I will suggest to accept
"Krap"
comment(s) as an answer.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
========
Werner
Main Topics
Browse All Topics





by: KrapPosted on 2002-11-14 at 08:13:28ID: 7448908
This is due to the fact that "3" isn't part of the variable part of your arguments. It's a fixed parameter.
va_start(arg,num) means "start reading variable arguments in the arg variable, starting at the adress AFTER num's address".
This way, you can pass fixed AND variable arguments to your function, accessing fixed params with their name, and the variables one with va_arg, reading them in the order and knowing their size. You should allways initialize your variable list, with va_start, using the last fixed param.
For example, the printf(const char *format,...) function use the format string to know the size of the variable arguments (%s means it's a char *, %d an int, ...).
A really incomplete implementation should look like :
printf(const char *format, ...)
{
va_list arg;
char *cp;
int i;
long l;
float f;
// ...
char c1, c2;
int pos=0;
va_start(arg,format);
while (c1=format[pos++])
{
if (c1=='%')
{
if (c2=format[pos++])
{
switch (c2)
{
case 's' : cp=va_arg(arg,char *); break;
case 'd' : i=va_arg(arg,int); break;
case 'f' : f=va_arg(arg,float); break;
// ...
}
}
else
// ERROR
}
}
va_end(arg);
}
Hope this helps you to understand !