如何用 C++ 实现把字符串的所有大写变小写
1、创建工程

2、创建源文件a.cpp

3、编写代码
#include <iostream>using namespace std;int main(){ while(1){ char str[100]; cout<<"请输入内容__________以#结尾"<<endl; for(unsigned int i = 0; i < 100; i++) { scanf("%c",&str[i]); if(str[i]=='#') { str[i]='\0'; break; } }
for(i = 0; i < strlen(str); i++) if(str[i] >= 'A' && str[i] <= 'Z')//大写的字母 str[i] += 32;//转小写 std::cout << str << std::endl;} return 0;
}

4、运行程序,没毛病。

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:162
阅读量:28
阅读量:129
阅读量:110
阅读量:130