Advertisement
char * strlwr(char *str);
/* Program to convert a String to lower case letters */
#include<string.h>
#include<stdio.h>
int main()
{
char str1[] = "HURRAY! Victory!";
printf("Original String value : %s", str1);
printf("\n");
strupr(str1);
printf("String's upper case value : %s ", str1);
return 0;
}
Original string value : HURRAY! Victory!
String's upper case value : hurray! victory!
Advertisement
/* Program to convert a String to lower case letters withut strlwr() function */
#include<string.h>
#include<stdio.h>
int main()
{
char str[] = "Never Give Up!";
printf("Original String is : %s", str);
/* starting index in a char{} array is always zero, 0 */
int i=0;
while(str[i]!='\0')
{
int asc = str[i];
	
	/* When ASCII value of a space is found */
	if(asc==32)
	{
		/* we don't do anything */
	}
	/* When alphabetic characters are found */
	if(asc>=65 && asc<=90)
	{
		asc = asc + 32;
		str[i] = asc;
	}
	
	/* incrementing the index to point to next char value in string */
	i++;
}	
printf("\nString's lower case value : %s", str);
return 0;
}
Original String is : Never Give Up!
String's lower case value : never give up!
 
  
Advertisement 
Advertisement
Please check our latest addition
 
 
  C#, PYTHON and DJANGO 
Advertisement