-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_putstr_fd.c
38 lines (33 loc) · 1.55 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
38
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putstr_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lspohle <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/19 12:06:08 by lspohle #+# #+# */
/* Updated: 2022/12/19 13:04:57 by lspohle ### ########.fr */
/* */
/* ************************************************************************** */
// Note
// Prototyped as void ft_putstr_fd(char *s, int fd)
// -> outputs the string ’s’ to the given file descriptor
// -> external functions: write
// Links
// -> Open: https://man7.org/linux/man-pages/man2/open.2.html
// -> Prototyped as int open(const char *pathname, int flags)
// #include <fcntl.h>
// -> file desriptor is an integer that uniquely identifies an open file of
// the process
// -> 0 = stdin
// -> 1 = stdout
// -> 2 = stderr
#include "libft.h"
// Outputs the string ’s’ to the given file descriptor
void ft_putstr_fd(char *s, int fd)
{
int i;
i = -1;
while (s[++i])
write(fd, &s[i], 1);
}