J'ai une simple liste d'arguments. Et je veux juste l'imprimer sur stdout, mais j'obtiens une sortie câblée avant d'imprimer "end". Quelqu'un sait-il d'où viennent cette ligne vide et ces caractères illisibles ?
sortie :
start
hello
hello2
hello3
hello 4
UHAWAVAUATE1S1HHHE
end
void printTest(const char* msg, ...) {
va_list ap;
int i;
const char* curMsg=0;
va_start(ap, msg);
printf("start\n");
for(curMsg= msg ; curMsg!=0 ; curMsg = va_arg(ap, const char*)){
printf("%s\n", curMsg);
}
printf("end\n");
va_end(ap);
}
int main(){
printTest("hello", "hello2", "hello3", "hello 4");
return 0;
}