/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* printing.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: apago +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/04/05 04:09:39 by tischmid #+# #+# */ /* Updated: 2023/04/05 19:06:03 by apago ### ########.fr */ /* */ /* ************************************************************************** */ #include "ft_bsq.h" void ft_putchar(char c, int fd) { write(fd, &c, 1); } int ft_err(char *str, int exit_code) { ft_putstr(str, 2); return (exit_code); } void ft_putstr(char *str, int fd) { while (*str) ft_putchar(*str++, fd); } int ft_putnbr(int nb) { int n; if (nb < 0) { ft_putchar('-', 1); return (ft_putnbr(-nb) + 1); } n = 1; if (nb > 9) n += ft_putnbr(nb / 10); ft_putchar(nb % 10 + '0', 1); return (n); } void print_map(t_map *map, int as_numbers) { int i; int j; i = -1; while (++i < map->meta.height) { j = -1; while (++j < map->meta.width) { if (as_numbers) { ft_putnbr(map->data[i * map->meta.width + j]); } else ft_putchar(map->data[i * map->meta.width + j], 1); } ft_putchar('\n', 1); } }