Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.95 KB | None | 0 0
  1. #include <unistd.h>
  2. #include <fcntl.h>
  3. #include "libft/libft.h"
  4. #include <stdlib.h>
  5.  
  6. char        **read_func()
  7. {
  8.     int     fd;
  9.     char    c;
  10.     char    **buf;
  11.     int     i = 0;
  12.     int     j = 0;
  13.     int     count_i = 0;
  14.     int     count_j = 0;
  15.  
  16.     buf = ft_memalloc(26);                      //тут нужен ft_memalloc(words_counter())
  17.     while (i < 26)                              //тут в условии тож нужно i < words. Как его делать я не ебу,
  18.                                                 //но сделать надо
  19.         buf[i++] = malloc(sizeof(char) * (21)); //а еще строк дохуя
  20.     i = 0;
  21.     fd = open("test.txt", O_RDONLY);
  22.     while (read(fd, &c, 1))
  23.         while (count_i++ < 3)                   //здесь в условии тоже нужен words
  24.         {                                       //ну ты разберешься)        
  25.             while (count_j++ < 20)
  26.             {
  27.                 buf[i][j++] = c;
  28.                 read(fd, &c, 1);
  29.             }
  30.             buf[i][j] = '\0';
  31.             i++;
  32.             j = 0;
  33.             count_j = 0;
  34.             if (c == '\n')
  35.                 read(fd, &c, 1);
  36.         }
  37.     close(fd);
  38.     return (buf);
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement