比较小写和大写。

时间:2016-11-24 23:15:07

标签: c

感恩节快乐如果适用的话。我正在尝试创建一个我将来可以使用的功能。该函数应该能够接受一个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. 有没有更好的方法来比较指向大写和小写版本的指针?
  2. 只有一个请求,如果你知道一个可以帮助我的帖子,请指出我。

1 个答案:

答案 0 :(得分:1)

首先将字符转换为低位,然后进行比较。

tolower就是这个方法。参见例如c - convert a mixed-case string to all lower case

相关问题