我正在阅读The C Programming Language。这是一个问题,它是写一个程序来计算空白、制表符和换行符。现在我可以将\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);
}