在了解如何在不使用字符串转换函数的情况下将大写字母转换为小写字母之前,让我们来看一下使用转换函数将大写字母转换为小写字母的程序,然后您将清楚我们在程序中所做的事情:
#include <stdio.h> #include <string.h> int main(){ char string[50]; printf("enter a string to convert to lower case</p><p>"); gets(string); /reading the string printf("The string in lower case: %s</p><p>", strlwr(string)); //strlwr converts all upper to lower return 0; }
enter a string to convert to lower case CProgramming LangUage The string in lower case: cprogramming language
现在让我们看看不使用预定义函数将大写转换为小写的程序 -
#include<stdio.h> void 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]!='\0';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 : TUTORIALSPOINT The converted lower case string is : tutorialspoint
以上就是编写一个C程序,将大写字母转换为小写字母,不使用字符串转换函数的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号