本文介绍了Ç - 转换大写字母为小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有一个非常简单的程序。我只想把一个'A'到'一',但产量是给我'A'。
的#include<&stdio.h中GT;诠释主要(无效){
的putchar(低('A'));}低级(一)
int类型的;
{
如果((A> = 65)及及(一个或GT; = 90°))
A = A + 32;
返回;
}
解决方案
您搞砸了你的,如果
条件的第二部分。这应该是 A< = 90
另外,仅供参考,有一个C库函数 tolower的
的已经做了这个:
的#include<&文件ctype.h GT;
#包括LT&;&stdio.h中GT;诠释主(){
的putchar(tolower的('A'));
}
A really simple program. I just want to turn an 'A' into an 'a', but output is giving me 'A'.
#include <stdio.h>
int main(void) {
putchar(lower('A'));
}
lower(a)
int a;
{
if ((a >= 65) && (a >= 90))
a = a + 32;
return a;
}
解决方案
You messed up the second part of your if
condition. That should be a <= 90
.
Also, FYI, there is a C library function tolower
that does this already:
#include <ctype.h>
#include <stdio.h>
int main() {
putchar(tolower('A'));
}
这篇关于Ç - 转换大写字母为小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!