-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_putstr_fd.c
34 lines (32 loc) · 1.69 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putstr_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lmartin2 <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/02/24 10:01:39 by lmartin2 #+# #+# */
/* Updated: 2022/02/24 10:01:50 by lmartin2 ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
// The purpose of this function is to output a string to a specific file
// descriptor. It relies on another function ft_putchar_fd, which is assumed
// to be defined elsewhere in the code.
void ft_putstr_fd(char *s, int fd)
// The function ft_putstr_fd takes in a string s and an integer file
// descriptor fd.
{
// It first checks if the string s is NULL. If it is, the function returns
// without performing any operation.
if (!s)
return ;
// It first checks if the string s is NULL. If it is, the function returns
// without performing any operation.
while (*s)
// Inside the loop, it calls the ft_putchar_fd function to output the
// current character to the specified file descriptor fd.
ft_putchar_fd(*s++, fd);
// After iterating through all characters in the string, the function
// completes.
}