把字符串中的小写字母转换成大写字母
#include <string.h>
#include <stdio.h>
void UpperCase(char str[])
{
int i=0;
int len = strlen(str);
for(i=0; i<len; i++)
if(str[i] >= 'a' && str[i] <= 'z')
str[i] -= ('a'-'A');
}
int main(void)
{
char str[] = "aBcDeF";
printf("length of the string \"aBcDeF\" = %d\n", sizeof(str)/sizeof(str[0]));
UpperCase(str);
printf("%s\n",str);
return 0;
}
/*
length of the string "aBcDeF" = 7
ABCDEF
请按任意键继续. . .
*/