> For the complete documentation index, see [llms.txt](https://42-guide.gitbook.io/42-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://42-guide.gitbook.io/42-guide/piscine-life/c02/ft_strlowcase.md).

# ft\_strlowcase

**Objective:**

Create a function that transforms all uppercase letters in a string into lowercase letters. The function modifies the original string and returns it.

***

**Turn-in Requirements:**

* **Directory:** `ex08/`
* **File:** `ft_strlowcase.c`
* **Allowed Functions:** None

***

**Prototype:**

```c
char *ft_strlowcase(char *str);
```

***

**Implementation:**

**Original Implementation:**

```c
char *ft_strlowcase(char *str)
{
    int i;

    i = 0;
    while (str[i] != '\0') // Loop through each character in the string
    {
        // If the character is an uppercase letter ('A' to 'Z'), convert it to lowercase
        if (str[i] >= 65 && str[i] <= 90)
            str[i] += 32; // Add 32 to convert uppercase to lowercase
        i++;
    }
    return (str); // Return the modified string
}
```

**Explanation:**

* **Input Parameter:**\
  The function takes a single parameter, `str`, which is a pointer to the first character of the string.
* **Conversion Logic:**
  * If a character is within the range `'A'` to `'Z'`, adding the difference between `32` converts it to lowercase.
  * This transformation is done directly on the original string.
* **Return Value:**\
  The function returns the pointer to the modified string.

***

**Example Usage:**

```c
#include <stdio.h>

char *ft_strlowcase(char *str);

int main()
{
    char str1[] = "HELLO WORLD";
    char str2[] = "42BERLIN";
    char str3[] = "";
    char str4[] = "alreadylowercase";

    printf("%s\n", ft_strlowcase(str1)); // Output: hello world
    printf("%s\n", ft_strlowcase(str2)); // Output: 42berlin
    printf("%s\n", ft_strlowcase(str3)); // Output: (empty string)
    printf("%s\n", ft_strlowcase(str4)); // Output: alreadylowercase
    return 0;
}
```

***

**Explanation of Outputs:**

* `"HELLO WORLD"`: All uppercase letters are converted to lowercase.
* `"42BERLIN"`: Only uppercase letters (`B`, `E`, `R`, `L`, `I`, `N`) are converted.
* `""`: The empty string remains unchanged.
* `"alreadylowercase"`: The function leaves lowercase letters unchanged.

***

**Notes:**

* Remove or comment out the `main` function when submitting your code.
* Ensure your code adheres to the Norminette coding standards.
* This implementation is efficient, with an `O(n)` time complexity where `n` is the length of the string.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://42-guide.gitbook.io/42-guide/piscine-life/c02/ft_strlowcase.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
