-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_putstr_fd.c
37 lines (36 loc) · 1.71 KB
/
ft_putstr_fd.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putstr_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: oostapen <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/09 13:28:11 by oostapen #+# #+# */
/* Updated: 2024/04/15 16:59:12 by oostapen ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
* The `ft_putstr_fd` function writes the string `s` to the file
* descriptor `fd`. It takes two arguments: the string `s` and the file
* descriptor `fd`.
* If the string `s` is empty (i.e., the first character
* of the string is the null character), the function does nothing and
* returns control.
* Then the `write` function is called with three arguments:
* the file descriptor `fd`, the string `s`, and the length of the string `s`
* (which is returned by the `ft_strlen` function). The `write` function
* writes the string `s` to the file descriptor `fd`.
* A file descriptor is
* an integer identifier of an open file or other input/output resource,
* such as a socket or pipe.
* input 0
* output 1
* error 2
*/
void ft_putstr_fd(char *s, int fd)
{
if (!*s)
return ;
write(fd, s, ft_strlen(s));
}