有关字符大小写转换中的toupper与 islower、 isupper都有什么功能跟区别啊??

xiangxuf 2008-10-26 11:52:35
有关字符大小写转换中的toupper与 islower、 isupper都有什么功能跟区别啊??
...全文
254 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
CDH0699 2011-02-26
  • 打赏
  • 举报
回复
3Q~
vbcpascal 2008-10-26
  • 打赏
  • 举报
回复
toupper



原型:extern int toupper(int c);

用法:#include <ctype.h>

功能:将字符c转换为大写英文字母

说明:如果c为小写英文字母,则返回对应的大写字母;否则返回原来的值。

举例:


// toupper.c

#include <syslib.h>
#include <ctype.h>

main()
{
char *s="Hello, World!";
int i;

clrscr(); // clear screen
printf("%s\n",s);
for(i=0;i<strlen(s);i++)
{
putchar(toupper(s[i]));
}

getchar();
return 0;
}




islower



原型:extern int islower(int c);

用法:#include <ctype.h>

功能:判断字符c是否为小写英文字母

说明:当c为小写英文字母(a-z)时,返回非零值,否则返回零。

举例:

// islower.c

#include <syslib.h>
#include <ctype.h>

main()
{
int c;

clrscr(); // clear screen
c='a';
printf("%c:%s\n",c,islower(c)?"yes":"no");
c='A';
printf("%c:%s\n",c,islower(c)?"yes":"no");
c='7';
printf("%c:%s\n",c,islower(c)?"yes":"no");
getchar();
return 0;
}

相关函数:isupper




isupper



原型:extern int isupper(int c);

用法:#include <ctype.h>

功能:判断字符c是否为大写英文字母

说明:当c为大写英文字母(A-Z)时,返回非零值,否则返回零。

举例:

// isupper.c

#include <syslib.h>
#include <ctype.h>

main()
{
int c;

clrscr(); // clear screen
c='a';
printf("%c:%s\n",c,isupper(c)?"yes":"no");
c='A';
printf("%c:%s\n",c,isupper(c)?"yes":"no");
c='7';
printf("%c:%s\n",c,isupper(c)?"yes":"no");
getchar();
return 0;
}

相关函数:islower






HelloDan 2008-10-26
  • 打赏
  • 举报
回复
islower、 isupper
只是判断是不是太小写,

touppper是返回其大写的形式,但如果是这样 char test='a'; toupper(test);
//这里的test是不变的,但返回值有大写的。
  • 打赏
  • 举报
回复
touppper是转化
其他两个是判断大小写

65,211

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧