title: file->d_name into a variable in C
body: <p>I have a probleme with a program. 
  I need to take file name in a folder and put it in a variable. 
  I tried that:</p>
  
  <pre><code>#define _POSIX_SOURCE
  #include &lt;dirent.h&gt;
  #include &lt;errno.h&gt;
  #include &lt;sys/types.h&gt;
  #undef _POSIX_SOURCE
  #include &lt;stdio.h&gt;
  
  int main()
  {
      DIR *dir;
    struct dirent *file;
    char fileName;
    dir = opendir("../../incoming");
  
      while ((file = readdir(dir)) != NULL)
      printf("  %s\n", file-&gt;d_name);
      fileName = file-&gt;d_name;
      printf(fileName);
      closedir(dir);
      return 0;
  }
  </code></pre>
  
  <p>thx</p>