I wrote this program to read a standard input file,
eliminate all vowels and write the consonants to an
output file. My problem is once the input file is
read the program keeps running only returning a
"yyyyyy....etc" character (seems to be an infinite
loop). How can I make this program end once the characters in the input file are read? Thanks.
Code:
#include <ctype.h>
#include <stdio.h>
int is_vowel(int c);
int main(void)
{
int c;
FILE *ifp, *ofp;
ifp = fopen("textin.txt", "r");
ofp = fopen("textout.txt", "w");
while ((c = getc(ifp)) != 'EOF')
{
if (!is_vowel(c))
{
putc(c, ofp);
}
}
return 0;
}
int is_vowel(int c)
{
c = toupper(c);
return c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U';
}