Created
October 1, 2014 21:08
-
-
Save antonijn/74e2c9f9ab0c4d6d716f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum sound { | |
CONSONANT, | |
SHORT_VOWEL, | |
LONG_VOWEL, | |
}; | |
enum sound getsound(FILE *word) | |
{ | |
int ch = fgetc(word); | |
if (isconsonant(ch)) | |
return CONSONANT; | |
int nxt = fgetc(word); | |
if (nxt == EOF) | |
return LONG_VOWEL; | |
if (isvowel(nxt)) { | |
ungetc(nxt, word); | |
return LONG_VOWEL; | |
} | |
/* nxt is a consonant */ | |
int nxtnxt = fgetc(word); | |
if (nxtnxt == EOF) { | |
ungetc(nxt, word); | |
return SHORT_VOWEL; | |
} | |
ungetc(nxtnxt, word); | |
ungetc(nxt, word); | |
if (isconsonant(nxtnxt)) | |
return SHORT_VOWEL; | |
return LONG_VOWEL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment