【发布时间】:2015-06-10 20:26:01
【问题描述】:
我找不到如何解决这个练习:它是关于学习字符计数(我使用的是 Kernighan-Ritchie 版本)。我的问题栏说:
warning: format specifies type 'int' but the argument has type 'long' [-Wformat] printf("%1d\n", nc); ^ %1ld
这是代码:
#include <stdio.h>
int main()
{
long nc;
nc = 0;
while (getchar() != EOF)
++nc;
printf("%1d\n", nc);
}
我在 Mac 上使用 Qt Creator 3.1.1。 Xcode 版本 6.2 (6C131e) 上的相同问题。
有什么帮助吗?提前致谢。
【问题讨论】:
-
This
printfreference 可能会在未来出现。 -
你看错了
1和l。 -
@BLUEPIXY , 1 不需要吧?
-
@CoolGuy 我认为这不需要计算字符数的结果。
标签: c types arguments long-integer