title: matching the ls command output
body: <p>I'm trying to code the ls command. I have the following function that prints each file name :</p>
  
  <pre><code>int ft_list(const char *filename)
  {
      DIR *dirp;
      struct dirent *dir;
  
      if (!(dirp = opendir(filename)))
          return (-1);
      while ((dir = readdir(dirp)))
      {
          if (dir-&gt;d_name[0] != '.')
              ft_putendl(dir-&gt;d_name);
      }
      closedir(dirp);
      return (0);
  }
  </code></pre>
  
  <p>The ls command prints the files organized into columns to fit the screen width. I have read about it and I think it uses the <code>ioctl</code> standard library function, but I can't find any details. How exactly can I do this?</p>