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