我正在阅读《C程序设计语言》。这里有一个问题,要求编写一个程序来计算空格、制表符和换行符。现在我知道可以使用\n表示换行符,\t表示制表符,但是我第一次听说空格!空格到底是什么意思?对于换行符和制表符,我已经编译了以下程序:
#include <stdio.h>
/* program to count blanks, tabs, and newlines */
main (){
long blanks, tabs, newlines, input;
blanks = 0;
tabs = 0;
newlines = 0;
input = 0;
while ((input = getchar()) != EOF)
if (input == '\n')
++newlines;
else if (input == '\t')
++tabs;
printf("Total newlines: %ld\nTotal Tabs: %ld", newlines, tabs);
}