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。不幸的是我沒有找到我要找的東西。
問:
- 有沒有更好的方式來指針比較大寫和小寫版本?
只是一個請求,如果你知道一個帖子,將幫助我請指向它。
'isalpha'。 isvowel不存在於標準C中。'int x' - >'int x = 0','char tmparry [strlen(codeit)];' - >'char tmparry [strlen(codeit)+1];'then空終止。 – BLUEPIXY
@BLUEPIXY是的,這是有道理的。謝謝你謝謝:)我沒有看到未來如何可能導致問題。 –
順便說一下,你有一個明顯的邏輯錯誤,因爲一個字母不能是小寫的元音和大寫的元音。 – djechlin