-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_ft_putchar_fd.c
40 lines (37 loc) · 1.42 KB
/
test_ft_putchar_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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* test_ft_putchar_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jliew <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/07/07 13:47:23 by jliew #+# #+# */
/* Updated: 2020/07/09 23:21:06 by jliew ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <fcntl.h>
#include "libft.h"
int main(int argc, char **argv)
{
if (argc == 1)
{
printf("------------------------------------\n");
printf(" void ft_putchar_fd(char c, int fd)\n");
printf("------------------------------------\n");
printf("usage [manual]:\n");
printf("1. a <char c>\n");
}
else
{
char c;
int fd;
c = argv[1][0];
fd = open("42", O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
if (fd == -1)
printf("open failed\n");
ft_putchar_fd(c, fd);
if (close(fd) == -1)
printf("close failed\n");
}
}