title: Reading current directory, printing results based on file attributes
body: <p>I am having a bit of trouble creating a C program that reads the current directory, prints the file path, and contents.</p>
  
  <p>For each file found in the directory the contents should be printed based on whether they are a directory, a file, or executable.</p>
  
  <p>I have the main components working just unsure how to sort the files output after using the opendir() / closedir() command </p>
  
  <p>eg. end output:</p>
  
  <pre><code>/home/documents/folder1
  File:       help.txt
  File:       me.txt
  Executable: plz
  File:       thankyou.c  
  </code></pre>
  
  <p>Current code:</p>
  
  <pre><code>struct dirent *de;  // Pointer for directory entry
  
  // opendir() returns a pointer of DIR type.
  DIR *dir = opendir(".");//opens current direcotry
  
  if (dir == NULL)  // opendir returns NULL if couldn't open directory
  {
      printf("ERROR: Could not open current directory" );
      return 1;
  }
  
  // for readdir()
  while ((de = readdir(dir)) != NULL){
  
        //if (Executable){}
        //else if (File){}
        //else if (Directory){}
          printf("%s\n", de-&gt;d_name);
  </code></pre>