警告:格式参数过多 - fprintf
pthread_t writeToFile = pthread_self ();
unsigned short iterate;
for (iterate = 0; iterate < 10000; iterate++)
{
fprintf (fp, " %d ", iterate, 4);
fprintf (fp, " %lu ", writeToFile, sizeof (pthread_t));
fprintf (fp, "\n", writeToFile, 1);
}
在 main() 中 fp = fopen("xyz", "w");
警告:警告:格式参数太多
从这里: http://www.cplusplus.com/reference/clibrary/cstdio/fprintf/
我的出了什么问题 代码?
gcc 版本 4.5.0
pthread_t writeToFile = pthread_self ();
unsigned short iterate;
for (iterate = 0; iterate < 10000; iterate++)
{
fprintf (fp, " %d ", iterate, 4);
fprintf (fp, " %lu ", writeToFile, sizeof (pthread_t));
fprintf (fp, "\n", writeToFile, 1);
}
In main () fp = fopen ("xyz", "w");
Warning: warning: too many arguments for format
From here: http://www.cplusplus.com/reference/clibrary/cstdio/fprintf/
What's wrong in my code?
gcc version 4.5.0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
让我们以您的第一个
fprintf
为例:" %d "
。它需要一个参数(一个 int),但你给它两个 - iterate 和 4。看起来你正在添加数据的大小,但你不应该。大概应该是:
在另外两句话中,甚至不清楚你想在文件中放入什么。
Let's take your first
fprintf
:" %d "
. it expects one argument (an int), but you give it two - iterate and 4.It seems like you are adding the size of the data, but you shouldn't. It should probably be:
In the other two sentences, it's not even clear what do you want to put in the file.