我编写了这个函数来将预设的小写 str 转换为它的大写变体。我已经尝试了所有我知道的将小写转换为大写的不同配置,但是当我打印它时。它仍然以小写形式结束。所以我有点卡住了。
char* stoupper(char str[]);
char str[100]= "uppercase";
printf("%s" , stoupper(str)); // Test to make sure it is working
char* stoupper(char str[])
{
int i = 0;
while(str[i] != '\0')
{
if(str[i] >= 'A' && str[i] <= 'Z')
str[i] = str[i] + ('A' - 'a');
i++;
}
return str;
}
/* I've tried various variations of this function this is just the one i had first */