
在了解如何在不使用字符串转换函数的情况下将大写字母转换为小写字母之前,让我们来看一下使用转换函数将大写字母转换为小写字母的程序,然后您将清楚我们在程序中所做的事情:
示例
#include #include int main(){ char string[50]; printf("enter a string to convert to lower case"); gets(string); /reading the string printf("The string in lower case: %s
", strlwr(string)); //strlwr converts all upper to lower return 0;}
输出
enter a string to convert to lower caseCProgramming LangUageThe string in lower case: cprogramming language
现在让我们看看不使用预定义函数将大写转换为小写的程序 –
示例
#includevoid main(){ //Declaring variable for For loop (to read each position of alphabet) and string// int i; char string[40]; //Reading string// printf("Enter the string : "); gets(string); //For loop to read each alphabet// for(i=0;string[i]!=' ';i++){ if(string[i]>=65&&string[i]<=90){ string[i]=string[i]+32; } } printf("The converted lower case string is : "); puts(string);}
输出
Enter the string : TUTORIALSPOINTThe converted lower case string is : tutorialspoint
以上就是编写一个C程序,将大写字母转换为小写字母,不使用字符串转换函数的详细内容,更多请关注创想鸟其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/1444003.html
微信扫一扫
支付宝扫一扫