2016-11-24 7 views
0

ハッピー感謝祭が適用される場合。私は将来私が使うことができる関数を作成しようとしています。この関数はchar配列を受け取り、それをコード化できるはずです。 (私はコード部分で終わっていません)は小文字と大文字の両方と比較しています。

int codetut(char *codeit){ 
int x,y = 0; 
char tmparry[strlen(codeit)]; 
while(codeit[x] != '\0'){ 
    if((codeit[x] >= 'a' && codeit[x] <= 'z') || (codeit[x] >= 'A' && codeit[x] <= 'Z')){ //Set to look for capitals and commons 
     if((codeit[x] == 'a' || codeit[x] == 'e' || codeit[x] == 'i' || codeit[x] == 'o' || codeit[x] == 'u') && (codeit[x] == 'A' || codeit[x] == 'E' || codeit[x] == 'I' || codeit[x] == 'O' || codeit[x] == 'U')){ // set to look for vowels 
     tmparry[y] = codeit[x]; 

     x++,y++; 
     }else{ 

     x++,y; 
     } 
    }else{ 
    tmparry[y] = codeit[x]; 
    x++,y++; 
    } 
} 
printf("%s",tmparry); 
return 0; 
} 

私はここではhow to validate both lowercase and uppercase lettersを見ていました。残念ながら、私が探していたものは見つかりませんでした。

質問:

  1. 大文字と小文字の両方のバージョンへのポインタを比較するためのより良い方法はありますか?

投稿をご存知の場合は、私にそれを教えてください。

+1

「isalpha」。 isvowelは標準Cには存在しません。 'int x' - >' int x = 0'、 'char tmparry [strlen(codeit)];' - > 'char tmparry [strlen(codeit)+1];'ヌル終了します。 – BLUEPIXY

+0

@BLUEPIXYうん、それは理にかなっている。ありがとう、ありがとう)私はそれが将来どのように問題を引き起こすかを見ていませんでした。 –

+0

ところで、あなたは文字が小文字の母音と大文字の母音の両方になることができないという明らかな論理エラーがあります。 – djechlin

答えて

関連する問題