您好,欢迎访问一九零五行业门户网

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

在了解如何在不使用字符串转换函数的情况下将大写字母转换为小写字母之前,让我们来看一下使用转换函数将大写字母转换为小写字母的程序,然后您将清楚我们在程序中所做的事情:
示例#include <stdio.h>#include <string.h>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
现在让我们看看不使用预定义函数将大写转换为小写的程序 -
示例#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 : tutorialspointthe converted lower case string is : tutorialspoint
以上就是编写一个c程序,将大写字母转换为小写字母,不使用字符串转换函数的详细内容。
其它类似信息

推荐信息