fuck it open() does not work 😭
This commit is contained in:
9
fdf.h
9
fdf.h
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/12/11 05:10:42 by adjoly #+# #+# */
|
||||
/* Updated: 2023/12/20 10:21:53 by adjoly ### ########.fr */
|
||||
/* Updated: 2023/12/23 08:20:35 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -35,8 +35,9 @@ typedef struct s_map
|
||||
char *color;
|
||||
} t_map;
|
||||
|
||||
int ft_read_map(int fd, char **map);
|
||||
size_t ft_countline_fd(int fd);
|
||||
char **ft_getmap(char *file);
|
||||
// int ft_read_map(int fd, char **map);
|
||||
// size_t ft_countline_fd(int fd);
|
||||
// char **ft_getmap(char *file);
|
||||
// char *get_next_line(int fd);
|
||||
|
||||
#endif
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/12/01 17:11:59 by adjoly #+# #+# */
|
||||
/* Updated: 2023/12/18 09:18:43 by adjoly ### ########.fr */
|
||||
/* Updated: 2023/12/23 06:51:37 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -61,7 +61,7 @@ char *get_next_line(int fd)
|
||||
res = ft_calloc(1, 1);
|
||||
while (buf)
|
||||
{
|
||||
res = ft_strjoin(res, buf);
|
||||
res = ft_strjoinf(res, buf);
|
||||
if (!res)
|
||||
return (NULL);
|
||||
if (check_line(res, buf))
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/12/01 17:12:00 by adjoly #+# #+# */
|
||||
/* Updated: 2023/12/18 09:27:15 by adjoly ### ########.fr */
|
||||
/* Updated: 2023/12/23 06:51:07 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
# endif
|
||||
|
||||
char *get_next_line(int fd);
|
||||
char *ft_strjoin(const char *s1, const char *s2);
|
||||
char *ft_strjoinf(char *s1, char *s2);
|
||||
// size_t ft_strlen(char *s);
|
||||
// void *ft_calloc(size_t nmemb, size_t size);
|
||||
|
||||
|
Binary file not shown.
BIN
get_next_line/get_next_line_bonus.h.gch
Normal file
BIN
get_next_line/get_next_line_bonus.h.gch
Normal file
Binary file not shown.
@ -6,23 +6,24 @@
|
||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/12/01 17:12:02 by adjoly #+# #+# */
|
||||
/* Updated: 2023/12/15 05:38:33 by adjoly ### ########.fr */
|
||||
/* Updated: 2023/12/23 06:52:24 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "get_next_line.h"
|
||||
#include "../libft/libft.h"
|
||||
|
||||
size_t ft_strlen(char *s)
|
||||
{
|
||||
size_t i;
|
||||
// size_t ft_strlen(char *s)
|
||||
// {
|
||||
// size_t i;
|
||||
//
|
||||
// i = 0;
|
||||
// while (s[i])
|
||||
// i++;
|
||||
// return (i);
|
||||
// }
|
||||
|
||||
i = 0;
|
||||
while (s[i])
|
||||
i++;
|
||||
return (i);
|
||||
}
|
||||
|
||||
char *ft_strjoin(char *s1, char *s2)
|
||||
char *ft_strjoinf(char *s1, char *s2)
|
||||
{
|
||||
char *result;
|
||||
size_t i;
|
||||
|
Binary file not shown.
@ -6,15 +6,14 @@
|
||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/12/12 05:19:39 by adjoly #+# #+# */
|
||||
/* Updated: 2023/12/20 10:43:54 by adjoly ### ########.fr */
|
||||
/* Updated: 2023/12/23 08:29:30 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "fdf.h"
|
||||
#include "libft/libft.h"
|
||||
#include <chrono>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void ft_putstr(char *s){int i = 0;while(s[i]){write(1, &s[i], 1);i++;}}
|
||||
|
||||
size_t ft_countline_fd(int fd)
|
||||
@ -63,19 +62,22 @@ int ft_read_map(int fd, char **map)
|
||||
if (i == 0 && map[i] == NULL)
|
||||
return (-1);
|
||||
close(fd);
|
||||
map[i + 1] = NULL;
|
||||
return (i);
|
||||
}
|
||||
|
||||
char **ft_getmap(char *file)
|
||||
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);
|
||||
map = ft_calloc(sizeof(char), line_nb);
|
||||
close(fd);
|
||||
map = ft_calloc(sizeof(char), line_nb);
|
||||
printf("linenb %d", line_nb);
|
||||
fd = open(file, O_RDONLY);
|
||||
ft_read_map(fd, map);
|
||||
@ -129,14 +131,19 @@ t_map **ft_parse_map(char **mapfile)
|
||||
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
(void)ac;
|
||||
char **map;
|
||||
int i = 0;
|
||||
printf("%s", av[1]);
|
||||
map = ft_getmap(av[1]);
|
||||
(void)ac;
|
||||
ft_putstr("map read");
|
||||
while (map[i])
|
||||
{
|
||||
ft_putstr(map[i]);
|
||||
free(map[i]);
|
||||
i++;
|
||||
}
|
||||
free(map);
|
||||
}
|
||||
|
||||
//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
|
Reference in New Issue
Block a user