C: Passing variable number of arguments from one function to another -


so, here's small problem i'm facing right -> i'm trying write function accept char* message , variable number of arguments. function modify message little, , it'll call printf message , given parameters. essentialy, i'm trying write that:

void modifyandprintmessage(char* message,...){     char* newmessage; //copy message.     //here i'm modifying newmessage printed,and i'd print it.      //passed args won't changed in way.      printf(newmessage,...); //of course, won't work. ideas?     fflush(stdout);  } 

so, knows should make happen? i'd grateful :)

you want use varargs...

void modifyandprintmessage( char* message, ... ) {     // somehthing custom      va_list args;     va_start( args, message );      vprintf( newmessage, args );      va_end( args ); } 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -