I want to include optional parameters in my function but I don't know the correct syntax, can anyone help me out?
thanks
This is a discussion on including optional parameters in function within the C Programming forums, part of the General Programming Boards category; I want to include optional parameters in my function but I don't know the correct syntax, can anyone help me ...
I want to include optional parameters in my function but I don't know the correct syntax, can anyone help me out?
thanks
I take it by optional parameters you mean the same effect as printf? You can make use of the macros defined in stdarg.h.
-PreludeCode:#include <stdio.h> #include <stdlib.h> #include <stdarg.h> void va_Error ( const char *fmt, va_list args ) { vfprintf ( stderr, fmt, args ); } void Error ( const char *fmt, ... ) { va_list args; va_start ( args, fmt ); va_Error ( fmt, args ); va_end ( args ); exit ( EXIT_FAILURE ); } int main ( void ) { Error ( "Fatal error %d : %s\n", 1, "Stupid user" ); return EXIT_SUCCESS; }
My best code is written with the delete key.
what mean of "vfprintf " ?
>what mean of "vfprintf " ?
I was expecting this one.
http://www.rt.com/man/vfprintf.3.html
-Prelude
My best code is written with the delete key.
Thanks, that's what I was lookn' for