Ive been trying to get this program to work for the past two days and i cant seem to find whats wrong with it. bear, with me if its very obvious for you guys but a little hint would be much appreciated.
the purpose of this program is to check if user inputted character is a vowel or consonant in the Hawaiian language. the program is split into three different files, a header file, a .c file for two functions, and a driver.c file to test the functions. oh, and also a makefile to execute the program.
here is the header file
Code:
/* header file for letters.c */
int is_vowel(char ch);
int is_consonant(char ch);
#define TRUE 1
#define FALSE 0
and the .c file for the int is_vowel and int is_consonant functions.
Code:
/* functions that test if a character is a vowel or consonant in the hawaiian language. */
#include "letters.h"
int is_vowel(char ch)
{
switch(ch)
{
case 'a': return TRUE;
break;
case 'A': return TRUE;
break;
case 'e': return TRUE;
break;
case 'E': return TRUE;
break;
case 'i': return TRUE;
break;
case 'I': return TRUE;
break;
case 'o': return TRUE;
break;
case 'O': return TRUE;
break;
case 'u': return TRUE;
break;
default: return FALSE;
}
}
int is_consonant(char ch)
{
switch(ch)
{
case 'h': return TRUE;
break;
case 'H': return TRUE;
break;
case 'k': return TRUE;
break;
case 'K': return TRUE;
break;
case 'l': return TRUE;
break;
case 'L': return TRUE;
break;
case 'm': return TRUE;
break;
case 'M': return TRUE;
break;
case 'n': return TRUE;
break;
case 'N': return TRUE;
break;
case 'p': return TRUE;
break;
case 'P': return TRUE;
break;
case 'w': return TRUE;
break;
case 'W': return TRUE;
break;
case '`': return TRUE;
break;
default: return FALSE;
}
}
and the driver.c to test the two functions
Code:
/* driver to test letters.c */
#include "letters.h"
#include <stdio.h>
#define FLUSH while(getchar() != '\n');
main()
{
char ch;
printf("Please enter a Hawaiian letter to be tested for being either a vowel or consonant:");
while( (ch = getchar()) != EOF )
{
if( is_vowel(ch) == TRUE )
printf("The character is a vowel\n");
else
printf("The character is not a vowel or consonant\n");
if( is_consonant(ch) == TRUE )
printf("The character is a consonant");
else
printf("The character is not a vowel or consonant\n");
printf("Please enter the next character to be tested\n");
FLUSH
}
}
the problem i am having is whenever i compile and run the program and type in say the vowel "a", the program prints both "the character is a vowel" and "The character is not a vowel or consonant" statement. it does the same if the letter is a consonant.
....idk whats wrong????
Edit: just noticed, sorry for using an implicit main.