Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <unistd.h>
- #include <fcntl.h>
- #include "libft/libft.h"
- #include <stdlib.h>
- char **read_func()
- {
- int fd;
- char c;
- char **buf;
- int i = 0;
- int j = 0;
- int count_i = 0;
- int count_j = 0;
- buf = ft_memalloc(26); //тут нужен ft_memalloc(words_counter())
- while (i < 26) //тут в условии тож нужно i < words. Как его делать я не ебу,
- //но сделать надо
- buf[i++] = malloc(sizeof(char) * (21)); //а еще строк дохуя
- i = 0;
- fd = open("test.txt", O_RDONLY);
- while (read(fd, &c, 1))
- while (count_i++ < 3) //здесь в условии тоже нужен words
- { //ну ты разберешься)
- while (count_j++ < 20)
- {
- buf[i][j++] = c;
- read(fd, &c, 1);
- }
- buf[i][j] = '\0';
- i++;
- j = 0;
- count_j = 0;
- if (c == '\n')
- read(fd, &c, 1);
- }
- close(fd);
- return (buf);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement