gpt4 book ai didi

C程序警告: format not a string literal and no format arguments

转载 作者:行者123 更新时间:2023-11-30 19:58:29 27 4
gpt4 key购买 nike

我正在使用-

char str[200];
...
sprintf(str,"%s", val)
msg(str);
sprintf(str, "%s: %s",timestr,"\n recv -");
msg(str);
...
}
void msg(const char str[])
{
...
fprintf(fp, str);
...
}

警告:格式不是字符串文字,也没有格式参数

如何解决这个问题?

最佳答案

你需要改变你的

fprintf(fp, str);

fprintf(fp, "%s", str);
^
|

在您的代码中,您缺少格式说明符“%s”

请查看fprintf()的手册页 here了解更多详情。

关于C程序警告: format not a string literal and no format arguments,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27189174/

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