Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #define SIZE 10
- #define LEN 30
- #define ENGLISH 26
- void myFgets(char str [][LEN] , int len);
- int allLetters(char str[][LEN], int placer, char letters[], int counter[]);
- int main()
- {
- char str [SIZE][LEN] = {0};
- int i = 0;
- int exit = 0;
- int len = 0;
- int c[1] = {0};
- //all the letters in English language
- char letters[ENGLISH+1] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0};
- printf("Enter up to 10 words and try to make a pangram: \n");
- for(i = 0; i < SIZE && exit != 1; i++)
- {
- myFgets(str , SIZE);
- exit = allLetters(words ,i ,letters, c);
- }
- if(exit == 1)
- {
- printf("It's a pangram?\nYES!!");
- }
- else
- {
- printf("It's a pangram?\nNO!!");
- }
- return 0;
- }
- /*
- The function checking a word to see if it has all the letters.
- Input: the string and the len
- Output: None
- */
- int allLetters(char str[][LEN], int placer, char letters[], int c[])
- {
- int i = 0; //variables
- int j = 0;
- int exit = 0;
- for(i = 0; i < strlen(words[placer]); i++)
- {
- for(j = 0; j < ENGLISH+1 ; j++)
- {
- if(words[placer][i] == letters[j])
- {
- letters[j] = 'Z';
- c[0] = c[0] + 1;
- }
- }
- }
- if(c[0] == ENGLISH)
- {
- exit = 1;
- }
- return exit;
- }
- /*
- get the words into the string and delete the spaces
- Input: the string and the len
- Output: None
- */
- void myFgets(char str [][LEN] , int len )
- {
- int i = 0;
- fgets(str[i] , LEN , stdin);
- str[i][strcspn(str[i],"\n")]=0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement