sync
This commit is contained in:
31
Rush_02/rush-02/ex00/dictionnaries/dictionnaries.c
Normal file
31
Rush_02/rush-02/ex00/dictionnaries/dictionnaries.c
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include "../ft/ft.h"
|
||||
|
||||
#define BUF_SIZE 4096
|
||||
|
||||
// cc -Wall -Wextra -Werror -o a.out -L../ft -lft dictionnaries.c && ./a.out && rm a.out
|
||||
|
||||
int main()
|
||||
{
|
||||
int fd;
|
||||
int ret;
|
||||
char buf[BUF_SIZE + 1];
|
||||
fd = open ("numbers.dict", O_RDONLY);
|
||||
if (fd == -1)
|
||||
{
|
||||
ft_putstr("open () error");
|
||||
return (1);
|
||||
}
|
||||
ret = read(fd, buf, BUF_SIZE);
|
||||
buf[ret] = '\0';
|
||||
ft_putnbr(ret);
|
||||
ft_putstr(buf);
|
||||
if (close(fd) == -1)
|
||||
{
|
||||
ft_putstr("Close() error");
|
||||
return(1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
Reference in New Issue
Block a user