# ft\_putstr\_fd

### Subject

```
FT_PUTSTR_FD (simplified)

NAME
    ft_putstr_fd -- write a string on a specified file descriptor
SYNOPSIS
    void ft_putstr_fd(char *s, int fd);
DESCRIPTION
    Write the string s on the file descriptor fd.
PARAMETERS
    s: string to write
    fd: file descriptor on which to write
RETURN VALUES
    ft_putstr_fd() does not return anything
AUTHORIZED EXTERNAL FUNCTIONS
    write(2)
```

### Understandable explanation

This one is pretty straight forward, you already know how to write the `ft_putstr()` function, if you don't remember, look back at what you did during your Piscine.

### Hints

Take a look at the man for the `write(2)` function, the first parameter is... you guessed it ! A file descriptor, so I mean, do you really need to have the code for this ?

I hope you can figure it out.

### Commented solution

<details>

<summary>ft_putstr_fd</summary>

{% code title="ft\_putstr\_fd.c" overflow="wrap" lineNumbers="true" %}

```c
#include "libft.h"

void    ft_putstr_fd(char *str, int fd)
{
    int i;
    
    i = 0;
    while (str[i])
    {
        write(fd, &str[i], 1);
        i++;
    }
}
```

{% endcode %}

</details>


---

# Agent Instructions: 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-cursus.gitbook.io/guide/0-rank-00/libft/additional-functions/ft_putstr_fd.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.
