我只回答了一个问题给K & R,它是“写计数空格,制表符和换行符程序”K&R第1.5.3行计数
而且我的继承人代码
#include <stdio.h>
#include <stdlib.h>
main()
{
/* Program counts Number of lines, Spaces, and Tabs from user input*/
int c, nl,tabs,spaces;
spaces = 0;
tabs = 0;
nl = 0;
while ((c = getchar()) != EOF)
if(c =='\t')
++tabs;
else if(c==' ')
++spaces;
else if (c == '\n')
++nl;
printf("Newlines %d\nTabs %d\nSpaces %d", nl, tabs, spaces);
return 0;
}
的输出运行完全一样.. 但书得到了不同的答案。 所以我不正确?
它不需要像书中一样编写程序。它可以用很多方式完成。 – ameyCU
谢谢,我以为我错了 – Saitama
换行数和行数注意它们不一定一致。 – BLUEPIXY