That's okay, I type slow. This is based on what is in the FAQ.
Code:
//
// Base: http://faq.cprogramming.com/cgi-bin/...&id=1044780608
//
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <dirent.h>
int main(void)
{
std::vector<std::string> filename;
DIR *d = opendir(".");
if ( d )
{
struct dirent *dir;
// Load vector with filenames.
while ( (dir = readdir(d)) != NULL )
{
filename.push_back(dir->d_name);
}
closedir(d);
}
// Show contents of vector.
std::copy(filename.begin(), filename.end(),
std::ostream_iterator<std::string> (std::cout, "\n"));
return 0;
}
If it doesn't work for you, you may want to visit the FAQ to find one that is more likely to work.