c 语言 编写一个程序使字符串大写转变小写的代码例如键盘输入 abCwd woRd 将其转化为 abcwd word
时间: 2024-03-08 13:46:13 浏览: 13
好的,以下是 C 语言代码示例:
```c
#include <stdio.h>
#include <ctype.h>
int main() {
char str[100];
printf("请输入一个字符串:");
scanf("%s", str);
for (int i = 0; str[i]; i++) {
str[i] = tolower(str[i]);
}
printf("转换后的字符串为:%s", str);
return 0;
}
```
这个程序首先使用 `scanf()` 函数从键盘输入一个字符串,并将其存储在 `str` 数组中。然后程序遍历字符串中的每个字符,将其转换为小写字符。最后,程序打印出转换后的字符串。
相关推荐
![py](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pptx](https://img-home.csdnimg.cn/images/20210720083543.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)