C strlwr() Function

The strlwr() function in C is used to convert all uppercase characters in a string to lowercase. This function is part of some C libraries like the C Run-Time Library (CRT), but it is not part of the standard C library.

Syntax of strlwr()

The syntax of the strlwr() function is as follows:

Syntax:

                        
char *strlwr(char *str);
                        
                    

The function takes one argument:

The function returns a pointer to the modified string with all lowercase characters.

Example of strlwr() Function

Here is an example that demonstrates how the strlwr() function works. Since it is not part of the standard C library, you may need to implement it or use a compatible library.

Example:

                        
#include <stdio.h>
#include <ctype.h>  
// For the standard library functions
        
// Function to convert string to lowercase (implementation of strlwr)
char* strlwr(char* str) {
    for (int i = 0; str[i]; i++) {
        if (str[i] >= 'A' && str[i] <= 'Z') {
            str[i] = str[i] + ('a' - 'A');  // Convert to lowercase
                }
            }
            return str;
    }
        
    int main() {
        char str[] = "HELLO WORLD!";
                
        printf("Original String: %s\n", str);
                
        // Convert the string to lowercase
        strlwr(str);
                
        printf("Lowercase String: %s\n", str);
                
        return 0;
}
                        
                    

Output:

Original String: HELLO WORLD!
Lowercase String: hello world!

Explanation of the Example

In this example:

Important Notes