简体   繁体   English

有人可以帮我找出为什么没有输出吗?

[英]Can someone help me to find why there's no output?

#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void) {
   char str[50];
   int count[26] = {0};
   int x;
   int len;
   int max;

printf("Enter your input: ");
scanf("%s", str);

while( ! feof(stdin)) {
  len = strlen(str);
  for(x = 0; x < len; ++x) {
    char ch = str[x];
    int sub = ch - 97;
    count[sub] = count[sub] + 1;
  }
  scanf("%s", str);
}
max = count[0];
for(x = 0; x < len; ++x) {
    if(count[x] > max){
      max = count[x];
    }
}

printf("Missing letters: ");
for(x = 0; x < 26; ++x) {
  if(count[x] == 0) {
    x = x + 97;
    printf("%c", x);
  }
}
printf("\n");
return 0;
}

I'm new to C and I've been trying to fix this for a few hours now and I'm just not understanding.我是C新手,我已经尝试解决这个问题几个小时了,但我只是不明白。 I think the issue is with the while loop, but I've just started coding I have no idea.我认为问题出在while循环上,但我刚刚开始编码,我不知道。 Does anything jump out at anyone?有什么东西会跳到任何人身上吗? This is supposed to read a sentence and output the letters that were not seen .这应该读取一个句子并输出未见过的字母 Thank you.谢谢你。

Your while loop only terminates when there is an EOF.您的 while 循环仅在有 EOF 时终止。 Use Ctrl^D to send the EOF signal to escape the feof function.使用 Ctrl^D 发送 EOF 信号以逃避 feof 函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM