I have made one simple variable argument list function in C. But it does not work. When I call that function with one argument, and then check that argument inside that function, that argument lost its value. e.g. In the following code, when I check the value of the "format" it always remain NULL .i.e. It is always displaying "format is NULL." in the debug message. Please guide me, what are the possibilities for this cause.
Calling the function: lcdPrintf( "Change" );
int lcdPrintf( char * format, ... )
{
if ( *format ) {
printf("format is not NULL.\r\n");
}
else {
printf("format is NULL.\r\n");
}
return -1;
}
format, not*format. Anyway, I don't see how it can tell you 'format is NULL'. Unless you called it with lcdPrintf("") perhaps?