diff --git a/a.out b/a.out index 56ff783..91644eb 100755 Binary files a/a.out and b/a.out differ diff --git a/fdf.h.gch b/fdf.h.gch index 031b424..da070cd 100644 Binary files a/fdf.h.gch and b/fdf.h.gch differ diff --git a/font.ttf b/font.ttf deleted file mode 100644 index 85c1472..0000000 Binary files a/font.ttf and /dev/null differ diff --git a/get_next_line/get_next_line.c b/get_next_line/get_next_line.c index 41260b6..e685568 100644 --- a/get_next_line/get_next_line.c +++ b/get_next_line/get_next_line.c @@ -6,12 +6,11 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/12/01 17:11:59 by adjoly #+# #+# */ -/* Updated: 2023/12/23 06:51:37 by adjoly ### ########.fr */ +/* Updated: 2024/01/04 00:45:17 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ #include "get_next_line.h" -#include "../libft/libft.h" char check_line(char *res, char *buf) { @@ -57,11 +56,11 @@ char *get_next_line(int fd) if (BUFFER_SIZE <= 0 || fd < 0 || fd > 1023) return (NULL); if (!buf) - buf = ft_calloc(sizeof(char), BUFFER_SIZE + 1); - res = ft_calloc(1, 1); + buf = ft_calloc_gnl(sizeof(char), BUFFER_SIZE + 1); + res = ft_calloc_gnl(1, 1); while (buf) { - res = ft_strjoinf(res, buf); + res = ft_strjoin_gnl(res, buf); if (!res) return (NULL); if (check_line(res, buf)) diff --git a/get_next_line/get_next_line.h b/get_next_line/get_next_line.h index 49ac8c0..ff4d72d 100644 --- a/get_next_line/get_next_line.h +++ b/get_next_line/get_next_line.h @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/12/01 17:12:00 by adjoly #+# #+# */ -/* Updated: 2023/12/23 06:51:07 by adjoly ### ########.fr */ +/* Updated: 2024/01/04 00:38:03 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,8 +21,8 @@ # endif char *get_next_line(int fd); -char *ft_strjoinf(char *s1, char *s2); -// size_t ft_strlen(char *s); -// void *ft_calloc(size_t nmemb, size_t size); +char *ft_strjoin_gnl(char *s1, char *s2); +size_t ft_strlen_gnl(char *s); +void *ft_calloc_gnl(size_t nmemb, size_t size); #endif \ No newline at end of file diff --git a/get_next_line/get_next_line.h.gch b/get_next_line/get_next_line.h.gch index a88c38f..22bcb36 100644 Binary files a/get_next_line/get_next_line.h.gch and b/get_next_line/get_next_line.h.gch differ diff --git a/get_next_line/get_next_line_bonus.c b/get_next_line/get_next_line_bonus.c deleted file mode 100644 index 90bc46a..0000000 --- a/get_next_line/get_next_line_bonus.c +++ /dev/null @@ -1,74 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* get_next_line_bonus.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: adjoly +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/01 17:11:59 by adjoly #+# #+# */ -/* Updated: 2023/12/15 05:51:22 by adjoly ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "get_next_line_bonus.h" - -char check_line(char *res, char *buf) -{ - int i; - int j; - - i = 0; - j = 0; - while (res[i] && res[i] != '\n') - i++; - if (res[i] == '\n') - { - i++; - while (res[i]) - { - buf[j] = res[i]; - i++; - j++; - } - buf[j] = 0; - res[i - j] = 0; - return (1); - } - return (0); -} - -char *ft_read_error(char **buf, char *res) -{ - free(*buf); - *buf = NULL; - if (res[0] != 0) - return (res); - free(res); - return (NULL); -} - -char *get_next_line(int fd) -{ - static char *buf[1024]; - char *res; - ssize_t bytes_read; - - if (BUFFER_SIZE <= 0 || fd < 0 || fd > 1023) - return (NULL); - if (!buf[fd]) - buf[fd] = ft_calloc(sizeof(char), BUFFER_SIZE + 1); - res = ft_calloc(1, 1); - while (buf[fd] && res) - { - res = ft_strjoin(res, buf[fd]); - if (!res) - return (NULL); - if (check_line(res, buf[fd])) - return (res); - bytes_read = read(fd, buf[fd], BUFFER_SIZE); - if (bytes_read < 1) - return (ft_read_error(&buf[fd], res)); - buf[fd][bytes_read] = 0; - } - return (NULL); -} diff --git a/get_next_line/get_next_line_bonus.h.gch b/get_next_line/get_next_line_bonus.h.gch deleted file mode 100644 index 403efb1..0000000 Binary files a/get_next_line/get_next_line_bonus.h.gch and /dev/null differ diff --git a/get_next_line/get_next_line_utils.c b/get_next_line/get_next_line_utils.c index 9fbd073..129049f 100644 --- a/get_next_line/get_next_line_utils.c +++ b/get_next_line/get_next_line_utils.c @@ -6,24 +6,24 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/12/01 17:12:02 by adjoly #+# #+# */ -/* Updated: 2023/12/23 06:52:24 by adjoly ### ########.fr */ +/* Updated: 2024/01/04 00:47:44 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ #include "get_next_line.h" #include "../libft/libft.h" -// size_t ft_strlen(char *s) +// size_t ft_strlen_gnl(char *s) // { // size_t i; -// + // i = 0; // while (s[i]) // i++; // return (i); // } -char *ft_strjoinf(char *s1, char *s2) +char *ft_strjoin_gnl(char *s1, char *s2) { char *result; size_t i; @@ -33,7 +33,7 @@ char *ft_strjoinf(char *s1, char *s2) j = 0; if (!s2) return (NULL); - result = ft_calloc((ft_strlen(s1) + ft_strlen(s2) + 1), sizeof(char)); + result = ft_calloc_gnl((ft_strlen(s1) + ft_strlen(s2) + 1), 1); if (result == NULL) return (NULL); while (s1[i]) @@ -52,7 +52,7 @@ char *ft_strjoinf(char *s1, char *s2) return (result); } -void *ft_calloc(size_t nmemb, size_t size) +void *ft_calloc_gnl(size_t nmemb, size_t size) { char *result; size_t i; diff --git a/get_next_line/get_next_line_utils_bonus.c b/get_next_line/get_next_line_utils_bonus.c deleted file mode 100644 index 0710d74..0000000 --- a/get_next_line/get_next_line_utils_bonus.c +++ /dev/null @@ -1,75 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* get_next_line_utils_bonus.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: adjoly +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/01 17:12:02 by adjoly #+# #+# */ -/* Updated: 2023/12/15 05:42:57 by adjoly ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "get_next_line_bonus.h" - -size_t ft_strlen(char *s) -{ - size_t i; - - i = 0; - while (s[i]) - i++; - return (i); -} - -char *ft_strjoin(char *s1, char *s2) -{ - char *result; - size_t i; - size_t j; - - i = 0; - j = 0; - if (!s2) - return (NULL); - result = ft_calloc((ft_strlen(s1) + ft_strlen(s2) + 1), sizeof(char)); - if (result == NULL) - return (NULL); - while (s1[i]) - { - result[i] = s1[i]; - i++; - } - while (s2[j]) - { - result[i] = s2[j]; - i++; - j++; - } - free(s1); - result[i] = '\0'; - return (result); -} - -void *ft_calloc(size_t nmemb, size_t size) -{ - char *result; - size_t i; - - i = 0; - if (nmemb == 0 || size == 0) - return (malloc(1)); - if (((unsigned long long)(size * nmemb) > 4294967295)) - return (NULL); - if ((int)size < 0 && (int)nmemb < 0) - return (NULL); - result = malloc(size * nmemb); - if (!result) - return (NULL); - while (i < (size * nmemb)) - { - *(unsigned char *)(result + i) = '\0'; - i++; - } - return (result); -} diff --git a/maps_reader.c b/maps_reader.c index 7e4107e..b2b5977 100644 --- a/maps_reader.c +++ b/maps_reader.c @@ -6,82 +6,30 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/12/12 05:19:39 by adjoly #+# #+# */ -/* Updated: 2023/12/23 08:29:30 by adjoly ### ########.fr */ +/* Updated: 2024/01/04 16:22:01 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ #include "fdf.h" #include "libft/libft.h" +#include +#include #include +#include "printf/ft_printf.h" -void ft_putstr(char *s){int i = 0;while(s[i]){write(1, &s[i], 1);i++;}} +// void ft_putstr(char *s){int i = 0;while(s[i]){write(1, &s[i], 1);i++;}} -size_t ft_countline_fd(int fd) +void ft_free(void **map) { - size_t i; - ssize_t rd; - size_t count; - char *buf; + int i; i = 0; - count = 1; - buf = ft_calloc(1, 1); - while (i <= ULONG_MAX) - { - rd = read(fd, buf, 1); - if (rd == -1) - break ; - else if (buf[0] == '\n') - count++; - i++; - } - if (i == 0) - return (-1); - return (count); -} - -size_t ft_countline(char **map) -{ - size_t i; - while (map[i]) - i++; - return (i); -} - -int ft_read_map(int fd, char **map) -{ - size_t i; - - i = 0; - while (map[i] && i <= ULONG_MAX) { - map[i] = get_next_line(fd); + free(map[i]); i++; } - if (i == 0 && map[i] == NULL) - return (-1); - close(fd); - map[i + 1] = NULL; - return (i); -} - -char **ft_getmap(const char *file) -{ - char **map; - int fd; - int line_nb; - - printf("mais รงรก fait quelque chose au moins\n"); - fd = open(file, O_RDONLY); - printf("file opened"); - line_nb = ft_countline_fd(fd); - close(fd); - map = ft_calloc(sizeof(char), line_nb); - printf("linenb %d", line_nb); - fd = open(file, O_RDONLY); - ft_read_map(fd, map); - return (map); + free(map); } t_map ft_split_height_color(char *tmp) @@ -93,57 +41,130 @@ t_map ft_split_height_color(char *tmp) while (tmp[i] && tmp[i] != ',') i++; if (tmp[i] == ',') - { - i++; - height_color.color = ft_strdup(&tmp[i]); - return (height_color); - } + height_color.color = ft_strdup(&tmp[i + 1]); else - { height_color.color = ft_strdup("0xFFFFFF"); - return (height_color); - } + return (height_color); } -t_map **ft_parse_map(char **mapfile) +size_t ft_countline_fd(int fd) +{ + size_t i; + ssize_t rd; + size_t count; + char *buf; + + i = 0; + count = 1; + buf = ft_calloc(1, 1); + while (i < ULONG_MAX) + { + rd = read(fd, buf, 1); + if (rd == -1 || rd == 0) + break ; + else if (buf[0] == '\n') + count++; + i++; + } + free(buf); + if (i == 0) + return (-1); + return (count); +} + +size_t ft_countline(char **map) +{ + size_t i; + + i = 0; + while (map[i]) + i++; + return (i); +} + +t_map **ft_parse_map(char **mapfile, size_t line_count) { int z; int x; - int line_count; char **tmp; t_map **parsed_map; + size_t i; z = 0; - line_count = ft_countline(mapfile); - parsed_map = ft_calloc(sizeof(t_map), line_count); + parsed_map = ft_calloc(sizeof(t_map *), line_count); while (mapfile[z]) { tmp = ft_split(mapfile[z], 32); + i = ft_countline(tmp); + parsed_map[z] = ft_calloc(i, sizeof(t_map *)); x = 0; while (tmp[x]) { parsed_map[z][x] = ft_split_height_color(tmp[x]); x++; } + parsed_map[z][x] = NULL; + z++; } + parsed_map[z] = NULL; return (parsed_map); } +char **ft_read_map(int fd, size_t map_size) +{ + size_t i; + char **map; + + i = 0; + map = ft_calloc(sizeof(char *), map_size + 1); + while (i < map_size) + { + map[i] = get_next_line(fd); + if (map[i] == NULL) + break ; + i++; + } + return (map); +} + +t_map **ft_getmap(char *file) +{ + t_map **map_parsed; + char **map; + int fd; + size_t line_nb; + + fd = open(file, O_RDONLY); + line_nb = ft_countline_fd(fd); + close(fd); + fd = open(file, O_RDONLY); + map = ft_read_map(fd, line_nb); + close(fd); + map_parsed = ft_parse_map(map, line_nb); + ft_free((void **)map); + return (map_parsed); +} + int main(int ac, char **av) { - char **map; + t_map **map; int i = 0; - printf("%s", av[1]); - map = ft_getmap(av[1]); + char *file_name; + + file_name = ft_strdup(av[1]); + map = ft_getmap(file_name); (void)ac; - ft_putstr("map read"); + ft_putstr("map read\n"); while (map[i]) { - ft_putstr(map[i]); - free(map[i]); + ft_printf("%s", map[i]->color); + ft_putchar('\n'); + ft_putnbr(map[i]->y); + ft_putchar('\n'); i++; } - free(map); + ft_free((void **)map); + return(0); } //cc maps_reader.c fdf.h get_next_line/get_next_line.c get_next_line/get_next_line.h get_next_line/get_next_line_utils.c libft/libft.a \ No newline at end of file diff --git a/printf/.gitignore b/printf/.gitignore new file mode 100644 index 0000000..ae2e347 --- /dev/null +++ b/printf/.gitignore @@ -0,0 +1 @@ +printfTester/ \ No newline at end of file diff --git a/printf/Makefile b/printf/Makefile new file mode 100644 index 0000000..65fa8b2 --- /dev/null +++ b/printf/Makefile @@ -0,0 +1,46 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: adjoly +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2023/11/17 12:35:27 by adjoly #+# #+# # +# Updated: 2023/11/20 15:55:52 by adjoly ### ########.fr # +# # +# **************************************************************************** # + +NAME = libftprintf.a + +CC = cc + +SRCS = ft_printf.c \ + ft_putchar.c \ + ft_putnbr.c \ + ft_putnbrbase.c \ + ft_putstr.c \ + ft_strlen.c \ + +OBJS = $(SRCS:.c=.o) + +FLAGS = -Werror -Wall -Wextra + +HEADER = libftprintf.h + +$(NAME): $(OBJS) + ar -rcs $(NAME) $(OBJS) + +%.o: %.c + $(CC) $(FLAGS) -I $(HEADER) $< -c -o $@ + +all: $(NAME) + +clean: + rm -f $(OBJS) + +fclean: clean + rm -f $(NAME) + +re: fclean all + +.PHONY: clean all re fclean \ No newline at end of file diff --git a/printf/ft_printf.c b/printf/ft_printf.c new file mode 100644 index 0000000..7144557 --- /dev/null +++ b/printf/ft_printf.c @@ -0,0 +1,92 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_printf.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/11/17 16:48:37 by adjoly #+# #+# */ +/* Updated: 2023/12/06 14:27:05 by adjoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "ft_printf.h" + +int ft_putaddr(void *ptr) +{ + int r; + + if (ptr == NULL) + return (write(1, "(nil)", 5)); + write(1, "0x", 2); + r = ft_putnbrbase_p((long unsigned int)ptr, "0123456789abcdef"); + return (2 + r); +} + +int ft_putnbrulong(unsigned int n) +{ + int len; + + len = 0; + if (n < 10) + len += write(1, &(char){n + '0'}, 1); + else + { + len += ft_putnbrulong(n / 10); + len += write(1, &(char){n % 10 + '0'}, 1); + } + return (len); +} + +int ft_printconversion(char conversion, va_list args) +{ + int count; + + count = 0; + if (conversion == '%') + count = ft_putchar('%'); + else if (conversion == 's') + count = ft_putstr(va_arg(args, char *)); + else if (conversion == 'c') + count = ft_putchar(va_arg(args, int)); + else if (conversion == 'i' || conversion == 'd') + count = ft_putnbr(va_arg(args, int)); + else if (conversion == 'u') + count = ft_putnbrulong(va_arg(args, unsigned int)); + else if (conversion == 'p') + count = ft_putaddr(va_arg(args, void *)); + else if (conversion == 'x') + count = ft_putnbrbase(va_arg(args, unsigned long), "0123456789abcdef"); + else if (conversion == 'X') + count = ft_putnbrbase(va_arg(args, unsigned long), "0123456789ABCDEF"); + return (count); +} + +int ft_printf(const char *format, ...) +{ + int i; + va_list args; + int count; + + va_start(args, format); + count = 0; + i = 0; + if (format == NULL) + return (-1); + while (format[i]) + { + if (format[i] == '%') + { + i++; + if (format[i]) + count += ft_printconversion(format[i], args); + else + return (-1); + } + else + count += ft_putchar(format[i]); + i++; + } + va_end(args); + return (count); +} diff --git a/printf/ft_printf.h b/printf/ft_printf.h new file mode 100644 index 0000000..fa3cdb7 --- /dev/null +++ b/printf/ft_printf.h @@ -0,0 +1,33 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_printf.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/11/17 16:50:36 by adjoly #+# #+# */ +/* Updated: 2023/11/22 14:00:38 by adjoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef FT_PRINTF_H +# define FT_PRINTF_H + +# include +# include +# include + +int ft_printf(const char *format, ...); +int ft_printconversion(char conversion, va_list args); +int ft_putnbrulong(unsigned int n); +int ft_putaddr(void *ptr); + +int ft_putstr(char *s); + +int ft_putnbrbase_p(unsigned long int n, char *base); +int ft_putnbrbase(unsigned int n, char *base); +int ft_putchar(char c); +int ft_putnbr(int n); +size_t ft_strlen(const char *s); + +#endif \ No newline at end of file diff --git a/printf/ft_printf.o b/printf/ft_printf.o new file mode 100644 index 0000000..5eaa2e2 Binary files /dev/null and b/printf/ft_printf.o differ diff --git a/printf/ft_putchar.c b/printf/ft_putchar.c new file mode 100644 index 0000000..7436489 --- /dev/null +++ b/printf/ft_putchar.c @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putchar.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/11/18 10:49:00 by adjoly #+# #+# */ +/* Updated: 2023/11/22 11:07:22 by adjoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "ft_printf.h" + +int ft_putchar(char c) +{ + write(1, &c, 1); + return (1); +} diff --git a/printf/ft_putchar.o b/printf/ft_putchar.o new file mode 100644 index 0000000..e31b0fe Binary files /dev/null and b/printf/ft_putchar.o differ diff --git a/printf/ft_putnbr.c b/printf/ft_putnbr.c new file mode 100644 index 0000000..cf709ff --- /dev/null +++ b/printf/ft_putnbr.c @@ -0,0 +1,36 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putnbr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/10/31 11:52:46 by adjoly #+# #+# */ +/* Updated: 2023/11/22 10:51:24 by adjoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "ft_printf.h" + +int ft_putnbr(int n) +{ + unsigned int nbr; + int len; + + len = 0; + if (n < 0) + { + len += write(1, "-", 1); + nbr = -n; + } + else + nbr = n; + if (nbr < 10) + len += write(1, &(char){nbr + '0'}, 1); + else + { + len += ft_putnbr(nbr / 10); + len += write(1, &(char){nbr % 10 + '0'}, 1); + } + return (len); +} diff --git a/printf/ft_putnbr.o b/printf/ft_putnbr.o new file mode 100644 index 0000000..279ad48 Binary files /dev/null and b/printf/ft_putnbr.o differ diff --git a/printf/ft_putnbrbase.c b/printf/ft_putnbrbase.c new file mode 100644 index 0000000..1866219 --- /dev/null +++ b/printf/ft_putnbrbase.c @@ -0,0 +1,47 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putnbrbase.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/11/18 10:57:44 by adjoly #+# #+# */ +/* Updated: 2023/11/22 14:02:37 by adjoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "ft_printf.h" + +int ft_putnbrbase(unsigned int n, char *base) +{ + unsigned int base_len; + int len; + + len = 0; + base_len = (int)ft_strlen(base); + if (n < base_len) + len += write(1, &base[n % base_len], 1); + else + { + len += ft_putnbrbase(n / base_len, base); + len += write(1, &base[n % base_len], 1); + } + return (len); +} + +int ft_putnbrbase_p(unsigned long int n, char *base) +{ + unsigned long int base_len; + int len; + + len = 0; + base_len = (int)ft_strlen(base); + if (n < base_len) + len += write(1, &base[n % base_len], 1); + else + { + len += ft_putnbrbase_p(n / base_len, base); + len += write(1, &base[n % base_len], 1); + } + return (len); +} diff --git a/printf/ft_putnbrbase.o b/printf/ft_putnbrbase.o new file mode 100644 index 0000000..b8ef8dc Binary files /dev/null and b/printf/ft_putnbrbase.o differ diff --git a/get_next_line/get_next_line_bonus.h b/printf/ft_putstr.c similarity index 58% rename from get_next_line/get_next_line_bonus.h rename to printf/ft_putstr.c index 51716d0..297a2e5 100644 --- a/get_next_line/get_next_line_bonus.h +++ b/printf/ft_putstr.c @@ -1,28 +1,31 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* get_next_line_bonus.h :+: :+: :+: */ +/* ft_putstr.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2023/12/01 17:12:00 by adjoly #+# #+# */ -/* Updated: 2023/12/15 05:43:09 by adjoly ### ########.fr */ +/* Created: 2023/10/31 11:45:55 by adjoly #+# #+# */ +/* Updated: 2023/12/06 15:51:38 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ -#ifndef GET_NEXT_LINE_BONUS_H -# define GET_NEXT_LINE_BONUS_H +#include "ft_printf.h" -# include -# include +int ft_putstr(char *s) +{ + int i; -# ifndef BUFFER_SIZE -# define BUFFER_SIZE 5 -# endif - -char *get_next_line(int fd); -char *ft_strjoin(char *s1, char *s2); -size_t ft_strlen(char *s); -void *ft_calloc(size_t nmemb, size_t size); - -#endif \ No newline at end of file + i = 0; + if (s == NULL) + { + write(1, "(null)", 6); + return (6); + } + while (s[i]) + { + write(1, &s[i], 1); + i++; + } + return (i); +} diff --git a/printf/ft_putstr.o b/printf/ft_putstr.o new file mode 100644 index 0000000..410f795 Binary files /dev/null and b/printf/ft_putstr.o differ diff --git a/printf/ft_strlen.c b/printf/ft_strlen.c new file mode 100644 index 0000000..ce68f8d --- /dev/null +++ b/printf/ft_strlen.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strlen.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/10/30 18:15:57 by adjoly #+# #+# */ +/* Updated: 2023/11/20 15:51:51 by adjoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "ft_printf.h" + +size_t ft_strlen(const char *s) +{ + int i; + + i = 0; + while (s[i]) + i++; + return (i); +} diff --git a/printf/ft_strlen.o b/printf/ft_strlen.o new file mode 100644 index 0000000..0bbb64d Binary files /dev/null and b/printf/ft_strlen.o differ diff --git a/printf/libftprintf.a b/printf/libftprintf.a new file mode 100644 index 0000000..93ec406 Binary files /dev/null and b/printf/libftprintf.a differ