1 #include<stdio.h>
2 int main()
3 {
4 int charNum = 0;
5 while(getchar() != EOF)
6 {
7 charNum++;
8 }
9 printf("The number of characters is %d\n", charNum);
2 int main()
3 {
4 int charNum = 0;
5 while(getchar() != EOF)
6 {
7 charNum++;
8 }
9 printf("The number of characters is %d\n", charNum);
10 }
以上是程序代码
[he@localhost ~]$ vim essay
[he@localhost ~]$ vim count.c
[he@localhost ~]$ gcc count.c
[he@localhost ~]$ ./a.out < essay > essayct
以上是linux代码
下面是运行截图