Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Written Hawaiian also has fairly simple spelling rules for determining if a word

ID: 3730929 • Letter: W

Question

Written Hawaiian also has fairly simple spelling rules for determining if a word is a valid word in the language (even if the meaning is unknown). They are:

All words contain only vowels and Hawaiian consonants.

All words end in a vowel.

Within a word, two consonants NEVER appear adjacent.

Write a program which reads lines of Hawaiian text from a file (using redirection, so you will not need to prompt), and lists each word found on a separate line indicating whether it is a valid Hawaiian spelling or it is invalid. Any non-letter characters (e.g. white space or punctuation characters) in the file should be treated as delimiters, but otherwise ignored and not appear in the output.

I have the files to determine if it is a Hawaiian letters, I'm just having trouble with making a function called "delimp()" to rid the program of any whitespace as well as the file to make this all happen "spchk.c".

letters.c

#include "letters.h"

int is_vowel(char c)
{
if ( c == 'A' || c == 'E' || c == 'I' || c == 'O' ||
c == 'U' || c == 'a' || c == 'e' || c == 'i' ||
c == 'o' || c == 'u')
{
return 1;
}
else{

return 0;
}
}

int is_h_consonant(char c)
{
if ( c == 'H' || c == 'h' || c == 'K' || c == 'k' ||
c == 'L' || c == 'l' || c == 'M' || c == 'm' ||
c == 'N' || c == 'n' || c == 'P' || c == 'p' ||
c == 'W' || c == 'w' || c == '`')
{
return 1;
}
else{

return 0;
}
}

letters.h

#define TRUE 1
#define FALSE 0

int is_vowel(char);
int is_h_consonant(char);

Thank you to whoever takes the time to help me out with this!

Explanation / Answer

int delimp(char c)

{

if(whitespace(c) || punctuation(c))

return TRUE;

return FALSE;

}

/* This function return True if there is either whitespace or punctuators */

int whitespace(char c)

{

if(c == ' ' || c == ' ' || c == ' ')

return TRUE;

return FALSE;

}

/* Function returns TRUE if c is a punctuation, else FALSE */

int punctuation(char c)

{

if (c == '.' || c == ',' || c == ';' || c == '?' || c == '!')

return TRUE;

return FALSE;

}