相关疑难解决方法(0)

什么是EOF以及如何触发它?

这是我的 C 源代码。

当我在 Ubuntu 中构建它时,它开始获取字符,但我不知道如何结束程序,因为它不会以输入ENTER或回车结束。

EOF是什么意思?我怎样才能触发它?

这个来源也来自丹尼斯·里奇的一本书:

#include <stdio.h>
    /* count digits, white space, others */
main ()
{
  int c, i, nwhite, nother;
  int ndigit[10];
  nwhite = nother = 0;
  for (i = 0; i < 10; ++i)
    ndigit[i] = 0;
  while ((c = getchar ()) != EOF)
    if (c >= '0' && c <= '9')
      ++ndigit[c - '0'];
    else if (c == ' ' || c == '\n' || c == '\t')
      ++nwhite;
    else
      ++nother; …
Run Code Online (Sandbox Code Playgroud)

command-line c

14
推荐指数
2
解决办法
8万
查看次数

标签 统计

c ×1

command-line ×1