1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
#include <stdio.h>
#include <ctype.h>
#define SIZE 20
int main(void)
{
char sentence[SIZE];
int i;
int Alphabet[26];
int count = 0;
char Alphabet[] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','r','s','t','u','v','w','x','y','z','\0'};
printf("Enter a line of text: ");
if (fgets(sentence, sizeof sentence, stdin)){
printf(sentence);
}
for(i=0; sentence[i] != '\0'; i++){
sentence[i] = tolower(sentence[i]);
}
printf(sentence);
getchar();
for (i=0; i<=26; ++i){
if (Alphabet[i]==sentence[i]){
count++;
}
}
return count;
}
|