[D�butant]Fonction � arguments variables
Bonjour � tous;
J'essaie d'utiliser une fonction � arguments variables; mais quand je l'appelle avec un seul argument �a ne marche, et la m�thode vsnprintf g�n�re une exception, mais avec deux param�tre �a marche.
Auriez-vous une solution ou une explication, pourquoi j'ai une exception � ce niveau. Merci � tous.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
CString GetMessages(const char* arg,...)
{
CString LstMsg;
char buf[4096], *p = buf;
const char* format="%s";
va_list args;
va_start(args, arg);
p += _vsnprintf(p, sizeof buf - 1, format, args);
while ( p > buf && isspace(p[-1]) ) {
*--p = '\0';
}
*p = '\0';
char msg[4096];
sprintf (msg, format, buf);
LstMsg=msg;
return LstMsg;
} |