#include<stdio.h>
int main()
{
long nc;
nc = 0;
while(getchar() != '0')
{
++nc;
}
printf("%ld/n", nc);
}
gcc char_counting.c -o char_counting.o
一种通常的调用方式:
[root@myhost c]# ./char_counting.o
123
450[回车]
6
通过linux管道来传递字符:
[root@myhost c]# echo helloworld0 | ./char_counting.o [回车]
10
[root@myhost c]#