#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. I think the issue is with the while
loop, but I've just started coding I have no idea. Does anything jump out at anyone? This is supposed to read a sentence and output the letters that were not seen. Thank you.