-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_putstr_fd.c
46 lines (42 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
39
40
41
42
43
44
45
46
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putstr_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mbutt <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/21 23:37:48 by mbutt #+# #+# */
/* Updated: 2019/03/21 23:50:35 by mbutt ### ########.fr */
/* */
/* ************************************************************************** */
/*
** Description - Outputs the string s to the file descriptor fd.
** Param#1 - The string to output.
** Param#2 - The file descriptor.
** Return Value - None.
** Libc functions - Write.
*/
#include "libft.h"
void ft_putstr_fd(char const *s, int fd)
{
int i;
i = 0;
if (s)
while (s[i])
{
write(fd, &s[i], 1);
i++;
}
}
/*
** int main (void)
** {
** char *s0 = "abc", *s1 = "def", *s2 = "ghi", *s3 = "jkl", *s4 = "mno";
** int fd0 = 0, fd1 = 1, fd2 = 2, fd3 = 3, fd4 = 4;
** ft_putstr_fd(s0, fd0); printf("\n");
** ft_putstr_fd(s1, fd1); printf("\n");
** ft_putstr_fd(s2, fd2); printf("\n");
** ft_putstr_fd(s3, fd3); printf("\n");
** ft_putstr_fd(s4, fd4); printf("\n");
** }
*/