使用for循环:double count;for(count = 0; getchar() != EOF; ++count);/* null statement */printf(%.0f\\n, count);
编程学习网为您整理以下代码实例,主要实现:计算输入中的字符数,希望可以帮到各位朋友。
使用for
循环:
double count;
for(count = 0; getchar() != EOF; ++count)
; /* null statement */
printf("%.0f\n", count);
使用while
循环:
long count = 0;
while(getchar() != EOF)
++count;
printf("%ld\n", count);