编写一个C程序,将大写字母转换为小写字母,不使用字符串转换函数

编写一个C程序,将大写字母转换为小写字母,不使用字符串转换函数

在了解如何在不使用字符串转换函数的情况下将大写字母转换为小写字母之前,让我们来看一下使用转换函数将大写字母转换为小写字母的程序,然后您将清楚我们在程序中所做的事情:

示例

#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 case
CProgramming LangUage
The string in lower case: cprogramming language

登录后复制

现在让我们看看不使用预定义函数将大写转换为小写的程序 –

示例

#include
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]!=’’;i++){
if(string[i]>=65&&string[i]

上一篇 python怎么排序
下一篇 在PHP中将一个目录的所有内容复制到另一个目录中
捡田螺的小男孩

捡田螺的小男孩

这个人很懒,什么都没有留下~

本月创作热力图