strlwr Function in C Programming

strlwr Function

Syntax:
char * strlwr(char *str)

strlwr(str) coverts str to all lowercase.

This function will convert all the uppercase characters in the string, which is provided as parameter, into lowercase. It does not take care whether it is the starting letter or not. It will convert every uppercase to lowercase.

For example

#include<stdio.h>
#include<conio.h>
int main()
{   
    char str[30]="www.COnlineCourse.com";           
    clrscr();
    printf("\n\nstr : %s\n\n",str);
    printf("strlwr(str) : %s\n",strlwr(str));
    getch();
    return 0;
}

here we declares the string str like this str[30]="www.COnlineCourse.com"; The string str is a character array of size 30.The character is stored like this



str[0]  <- 'w'
str[1]  <- 'w'
str[2]  <- 'w'
str[3]  <- '.'
str[4]  <- 'C'
str[5]  <- 'O'
str[6]  <- 'n'
str[7]  <- 'l'
str[8]  <- 'i'
str[9]  <- 'n'
str[10]   <-'e'                   
str[11]   <-'C'   
str[12]   <-'o'   
str[13]   <-'u'   
str[14]   <-'r'   
str[15]   <-'s'   
str[16]   <- 'e' 
str[17]   <- '.'
str[18]   <- 'c'
str[19]   <- 'o'
str[20]   <- 'm'
str[21]   <- '\n'
str[22]   <- 'garbage value'
str[23]   <- 'garbage value'
str[24]   <- 'garbage value'
str[25]   <- 'garbage value'
str[26]   <- 'garbage value'
str[27]   <- 'garbage value'
str[28]   <- 'garbage value'
str[29]   <- 'garbage value'

when we use the function strlwr(str) it will convert all characters stored in the character array str to lowercase.Then stored like this


str[0]  <- 'w'
str[1]  <- 'w'
str[2]  <- 'w'
str[3]  <- '.'
str[4]  <- 'c'
str[5]  <- 'o'
str[6]  <- 'n'
str[7]  <- 'l'
str[8]  <- 'i'
str[9]  <- 'n'
str[10]   <-'e'                   
str[11]   <-'c'   
str[12]   <-'o'   
str[13]   <-'u'   
str[14]   <-'r'   
str[15]   <-'s'   
str[16]   <- 'e' 
str[17]   <- '.'
str[18]   <- 'c'
str[19]   <- 'o'
str[20]   <- 'm'
str[21]   <- '\n'
str[22]   <- 'garbage value'
str[23]   <- 'garbage value'
str[24]   <- 'garbage value'
str[25]   <- 'garbage value'
str[26]   <- 'garbage value'
str[27]   <- 'garbage value'
str[28]   <- 'garbage value'
str[29]   <- 'garbage value'

so after using the function strlwr(str) the value of string str is"www.conlinecourse.com"

Example:

Ready to get started?

Ready to embark on your journey into the world of C programming? Our comprehensive course provides the perfect starting point for learners of all levels. With engaging lessons, hands-on exercises, and expert guidance, you'll gain the skills and confidence needed to excel in this fundamental programming language. Let's dive in and unlock the endless possibilities of C programming together!