Link to home
Start Free TrialLog in
Avatar of esotericRa
esotericRa

asked on

Getting Subdirectories Only From Path

Hello, Looking to get subdirectories from a path

I'm using the code below but it's not compiling correctly for me I think because I do not have that c runtime installed. Could you please tell me where to download/install what I need to compile this correctly?


// GetWoWUSRNAME.cpp : Defines the entry point for the console application.
//
 
#include "stdafx.h"
#include <iostream>
#include "windows.h"
#include <conio.h>
#include <string.h>
#include <sys/types.h>
#include <dirent.h>
using namespace std;
void PrintDirectory (const char* DirName);
 
void main()
{
	PrintDirectory("C:\\Program Files\\World of Warcraft\\WTF\\Account");
}
 
void PrintDirectory (const char* DirName)
{
DIR * dir = opendir(DirName);
readdir(dir);
 
while( dir->d_handle != -1 )
{
DIR* subdir = opendir (  dir->dd_dir.d_name);
if (  subdir) { // success, it is a directory
 
  cout << dir->dd_dir.d_name << "\n";
 
  closedir (subdir);
}
readdir(dir);
} 
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of itsmeandnobodyelse
itsmeandnobodyelse
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial