🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Darrell Tue, 11 Dec 1990 22:22
using the ellipsis (...)
#346
Author: Darrell
Date: Tue, 11 Dec 1990 22:22
28 lines
1288 bytes
How would one use va_start when no formal arguments are specified in 
the argument list?  For example suppose I wanted to write a function 
print_strs which would take an arbitrary number strings, terminated by 
a null string, and print them to cout.  


void print_strs(...)
{
  va_list ap;
  va_start(ap, ???);	// what arg should be used in place of ???

  while( 1 )  {
    char *sp = va_arg( ap, char* );
    if ( !sp ) break;
    cout << sp << "\n";
  }
  va_end( ap );
}


This is not the best example since there is no compelling reason not 
to define print_strs with the argument list ( char *sp1 ... ) and use 
sp1 in place of ???.  However, I do have a real need for a virtual 
member function with an ( ... ) argument list.


Thanks,
Darrell Shane
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads