C++转换大小写

函数 ------------------------说明

toupper(c) c是小写就返回大写;否则原样返回
tolower(c) c是大写就返回小写;否则原样返回

头文件

#include <cctype> 

下面一个例题;

#include <iostream>
#include <cstring>
#include <cctype>
using namespace std;
void g(char *p);
int main()
{ char s[100];
cin.getline(s,100);
g(s);
cout<<s<<endl;
return 0;
}
void g(char *p)
{int len=strlen(p);//测量长度
for(int i=0;i<len;i++)
p[i]=toupper(p[i]);
}

在这里插入图片描述
在这里插入图片描述

发布了15 篇原创文章 · 获赞 17 · 访问量 6927

猜你喜欢

转载自blog.csdn.net/weixin_45907018/article/details/104074988
今日推荐