Well you're mixing up the {} - adding them where they're not needed, and removing them where they are.
Does your editor preserve this indentation?Code:#include <stdio.h> #include <ctype.h> #include <string.h> int EWord(char *str); void LWord(char *str); int isVowel( char ch ) { int res = 0; ch = tolower( ch ); if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') res = 1; return res; } int beginsConsonant( char word[] ) { return !isVowel( word[0] ); } int main(void) { char Word[100]; printf( "Welcome to the Pig Latin Translator!\n\n" ); printf( "Please enter your word(s):\n\n" ); while(scanf( "%s", Word ) == 1) { if(stricmp( Word, "stop" ) == 0) return 0; if(EWord( Word )) LWord( Word ); } return 0; } int allConsonant( char word[] ) { int len = strlen( word ); int i, res = 1; for(i = 0 ; i < len ; i++) { if(isVowel( word[i] )) res = 0; } //!! ADDED return res; } void pigLatin( char word[] ) { if(beginsConsonant( word ) && !allConsonant( word )) { printf( "%s%cay ", &word[1], word[0] ); } else { printf( "%sway ", word ); } //!! REMOVED } }
There are many free code editors around which understand program indentation, and know how to match up {} so you can see whether they are balanced or not
Which OS / Compiler are you using



LinkBack URL
About LinkBacks


