title: C read file and print buffer
body: <p>I am learning C and I have been trying to read a file and print what I just read. I open the file and need to call another function to read and return the sentence that was just read.
  My function will return 1 if everything went fine or 0 otherwise.
  I have been trying to make it work for a while but I really dont get why I cant manage to give <code>line</code> its value. In the main, it always prints (null).</p>
  
  <p>The structure of the project has to stay the same, and I absolutely have to use <code>open</code> and <code>read</code>. Not fopen, or anything else...
  If someone can explain it to me that would be awesome.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;fcntl.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;string.h&gt;
  
  #define BUFF_SIZE 50
  
  int     read_buff_size(int const fd, char **line)
  {
      char    buf[BUFF_SIZE];
      int     a;
  
      a = read(fd, buf, BUFF_SIZE);
      buf[a] = '\0';
      *line = strdup(buf);
      return (1);
  }
  
  int     main(int ac, char **av)
  {
      char    *line;
      int     fd;
  
      if (ac != 2)
      {
          printf("error");
          return (0);
      }
      else
      {
          if((fd = open(av[1], O_RDONLY)) == -1)
          {
              printf("error");
              return (0);
          }
          else
          {
              if (read_buff_size(fd, &amp;line))
                  printf("%s\n", line);
          }
          close(fd);
      }
  }
  </code></pre>