#include <stdio.h>
#include <ctype.h>

void str_toupper(char s[]){
int i = 0;
while (s[i]){
s[i] = toupper(s[i]);
i++;
}
}

void str_tolower(char s[]){
int i = 0;
while (s[i]){
s[i] = tolower(s[i]);
i++;
}
}

int main(void){
char str[128];

printf("请输入字符串:");
scanf("%s", str);

str_toupper(str);
printf("大写字母:%s\n", str);

str_tolower(str);
printf("小写字母:%s\n", str);

return 0;
}

运行结果:
C语言 大小写字符转换_i++

int toupper(int c)函数: 将小写英文字母转换为相应的大写英文字母。

int tolower(int c)函数: 将大写英文字母转换为相应的小写英文字母。

注:
toupper 函数 和 tolower函数 都是<ctype.h>提供的库函数。
如果参数接收的字符不是英文字符,则函数 touppertolower将原样返回字符。
这两个函数转换的对象是半角的英文字符,不能转换汉字等全角字符。