Hi Guys,
Im trying to write a Variable-Length Argument List for my curses program. Im getting a segmentation fault because va_arg requires an terminating argument like CHAR *(NULL). I want break out of the while loop when there are no more arguments.
At the moment I have to pass CHAR *(NULL) as my last argument when I call my function.
e.g. init_process(name,name1, CHAR *(NULL));
How do I do it so that I can call the function like this:
init_process(name,name1) ;
currently this code works only if you pass CHAR *(NULL):
void init_process(char *name, ...)
{
int x=0;
char *new;
va_list argptr;
va_start(argptr,name);
while ((new = va_arg(argptr, char *)) != 0) /* this only works if char*(NULL) is passed */
{
strcpy(pop[x].name,new);
x++;
}
va_end (argptr);
Any ideas???
Thanks in advance
Johnny
Im trying to write a Variable-Length Argument List for my curses program. Im getting a segmentation fault because va_arg requires an terminating argument like CHAR *(NULL). I want break out of the while loop when there are no more arguments.
At the moment I have to pass CHAR *(NULL) as my last argument when I call my function.
e.g. init_process(name,name1, CHAR *(NULL));
How do I do it so that I can call the function like this:
init_process(name,name1) ;
currently this code works only if you pass CHAR *(NULL):
void init_process(char *name, ...)
{
int x=0;
char *new;
va_list argptr;
va_start(argptr,name);
while ((new = va_arg(argptr, char *)) != 0) /* this only works if char*(NULL) is passed */
{
strcpy(pop[x].name,new);
x++;
}
va_end (argptr);
Any ideas???
Thanks in advance
Johnny