unix C++: get the files from a folder

Hello everybody!
How can I get the list of files from a folder in C++ (unix)?

thanks in advance for any help!

regards

You can do this in plain C, no C++ class madness required.

// listdir.c
#include <sys/types.h>
#include <dirent.h>

#include <stdio.h>

int main(int argc, char *argv[])
{
  struct dirent *de=NULL;
  DIR *d=NULL;

  if(argc != 2)
  {
    fprintf(stderr,"Usage: %s dirname\n",argv[0]);
    return(1);
  }

  d=opendir(argv[1]);
  if(d == NULL)
  {
    perror("Couldn't open directory");
    return(2);
  }

  // Loop while not NULL
  while(de = readdir(d))
    printf("%s\n",de->d_name);

  closedir(d);
  return(0);
}

For more details, see 'man 3 opendir', 'man 3 readdir', and 'man 3 closedir'.

thanks a lot, Corona688!

regards