C
cornelis van der bent
Hi, the code below prints a garbage "world" value to <messages>;
"Hello " is fine. What can be the problem?
static char messages[LARGE_ENOUGH];
int writeText(char* text, char* format, ...)
{
va_list argumentList;
va_start(argumentList, format);
vsprintf(text, format, argumentList);
va_end(argumentList);
}
void writeMessage(char* format, ...)
{
va_list argumentList;
va_start(argumentList, format);
writeText(protocolText, format, argumentList);
va_end(argumentList);
}
void test(void)
{
writeMessage("Hello %s!\n", "world");
}
Thanks,
Cornelis
"Hello " is fine. What can be the problem?
static char messages[LARGE_ENOUGH];
int writeText(char* text, char* format, ...)
{
va_list argumentList;
va_start(argumentList, format);
vsprintf(text, format, argumentList);
va_end(argumentList);
}
void writeMessage(char* format, ...)
{
va_list argumentList;
va_start(argumentList, format);
writeText(protocolText, format, argumentList);
va_end(argumentList);
}
void test(void)
{
writeMessage("Hello %s!\n", "world");
}
Thanks,
Cornelis