The idea is simple. Folders or directories do not have any .extensions. So you could read all files into an array and filter out all the ones with dot extensions.
However, a more reliable way would be to use this example, taken from adrianxw's site.
using namespace std;
cout << "A very basic FindFirst/Next demo.\n" << endl;
// Find the first file
hFind = FindFirstFile("C:\\*.*", &FindData);
while (FindNextFile(hFind, &FindData))
//cout << FindData.cFileName;
if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
cout << FindData.cFileName;
cout << " File is a directory!";
cout << endl;
// Close the file handle
Just as a side note you can easily make directory's and remove as well using this example...
/* MAKEDIR.C */
#include <direct.h> //need this baby
int main( )
_mkdir( "c:\\treenef" );
printf( "Directory '\\treenef' was successfully created\n" );
//To remove the directory uncomment below
//if( _rmdir( "c:\\treenef" ) == 0 )
//printf( "Directory '\\treenef' was successfully removed\n" );