gpt4 book ai didi

使用 va_list 调用 printf

转载 作者:太空狗 更新时间:2023-10-29 16:18:58 24 4
gpt4 key购买 nike

void TestPrint(char* format, ...)
{
va_list argList;

va_start(argList, format);
printf(format, argList);
va_end(argList);
}


int main()
{
TestPrint("Test print %s %d\n", "string", 55);
return 0;
}

我需要得到:

Test print string 55

实际上,我得到了垃圾输出。这段代码有什么问题?

最佳答案

使用vprintf()相反。

关于使用 va_list 调用 printf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5977326/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com