> 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_str_is_lowercase.md).

# ft\_str\_is\_lowercase

**Objective:**

Create a function that checks whether a string contains only lowercase alphabetic characters (letters `a–z`). The function should return `1` if the string contains only lowercase letters (or is empty) and `0` otherwise.

***

**Turn-in Requirements:**

* **Directory:** `ex04/`
* **File:** `ft_str_is_lowercase.c`
* **Allowed Functions:** None

***

**Prototype:**

```c
int ft_str_is_lowercase(char *str);
```

***

**Implementation:**

Here’s how you can implement the function:

```c
// File: ft_str_is_lowercase.c

int ft_str_is_lowercase(char *str)
{
    int i;

    i = 0;
    while (str[i] != '\0') // Loop through each character of the string
    {
        // Check if the character is not within 'a'-'z'
        if (str[i] < 'a' || str[i] > 'z')
            return (0); // Return 0 if a non-lowercase character is found
        i++;
    }
    return (1); // Return 1 if all characters are lowercase or the string is empty
}
```

***

**Explanation:**

* **Input Parameter:**\
  The function takes a single parameter, `str`, which is a pointer to the first character of the input string.
* **Loop through the string:**\
  The `while` loop iterates through the string until it reaches the null terminator (`\0`).
* **Check each character:**
  * The condition checks if the current character is **outside** the range `'a'` to `'z'`.
  * If a non-lowercase character is found, the function immediately returns `0`.
* **Empty string:**\
  If the string is empty (i.e., `str[0] == '\0'`), the loop doesn’t execute, and the function returns `1`.

***

**Example Usage:**

```c
#include <stdio.h>

int ft_str_is_lowercase(char *str);

int main()
{
    printf("%d\n", ft_str_is_lowercase("hello"));       // Output: 1
    printf("%d\n", ft_str_is_lowercase("Hello"));       // Output: 0
    printf("%d\n", ft_str_is_lowercase(""));            // Output: 1
    printf("%d\n", ft_str_is_lowercase("hello123"));    // Output: 0
    return 0;
}
```

* **Explanation of Outputs:**
  * `"hello"`: All lowercase letters → returns `1`.
  * `"Hello"`: Contains uppercase letter `H` → returns `0`.
  * `""`: Empty string → returns `1`.
  * `"hello123"`: Contains non-alphabetic characters → returns `0`.

***

**Notes:**

* Remove or comment out the `main` function when submitting your code.
* Ensure your code adheres to the Norminette coding standards.
* Avoid including unnecessary files in your directory.


---

# 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_str_is_lowercase.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.
