I need to create a 2D string array and input to hi, up to 10 words, than to check if those words are pangram or not.
The program needs to stop receiving words if the words are pangram.
for example:
the
five
boxing
wizards
jump
quickly
It's a pangram?
Yes
but instead of stopping it's just keeps asking for words until it gets to 10. Also says that non-pangram sentences are pangram.
#include<stdio.h>
#include <string.h>
#define ROWS 10
#define COL 50
#define NUM_OF_LETTERS 26
int main()
{
char words[ROWS][COL] = {0};
char used []['z' - 'a' + 1] = {0};
int i = 0;
int j=0;
int count = 0;
printf("Enter up to 10 words try to make a pangram\n");
while(i<ROW&& count < NUM_OF_LETTERS)
{
fgets(words[i], ROW, stdin);
words[i][strcspn(words[i], "\n")] = 0;
int len = strlen(words[i]);
for(j=0;j<COL;j++)
{
if(strcmp(words[j] ,used[j]) == 0)
{
count++;
}
}
i++;
}
printf("It's a pangram?\n");
if (count >= NUM_OF_LETTERS)
{
printf("Yes!\n");
}
else
{
printf("No\n");
}
return 0;
}
And I can't use pointers.