A
Andrej Prsa
Hi!
If I declare two functions like this:
int execute_command (char *name, ...)
{
va_list args;
va_start (args, name);
my_func (1, args);
va_end (args);
}
int my_func (int argc, ...)
{
va_list args;
char *str;
va_start (args, argc);
str = va_arg (args, char *);
printf ("%s\n", str);
va_end (args);
}
and call them from e.g.
execute_command ("my_command", "my argument");
parsing of args is OK at the first function (e.g. if I cut & paste the
va_arg and printf part to the first function), but garbage is printed in
the second function. I'm surely missing something obvious, but I can't see
it. Help?
Thanks,
Andrej
If I declare two functions like this:
int execute_command (char *name, ...)
{
va_list args;
va_start (args, name);
my_func (1, args);
va_end (args);
}
int my_func (int argc, ...)
{
va_list args;
char *str;
va_start (args, argc);
str = va_arg (args, char *);
printf ("%s\n", str);
va_end (args);
}
and call them from e.g.
execute_command ("my_command", "my argument");
parsing of args is OK at the first function (e.g. if I cut & paste the
va_arg and printf part to the first function), but garbage is printed in
the second function. I'm surely missing something obvious, but I can't see
it. Help?
Thanks,
Andrej