Last active
December 24, 2015 12:38
-
-
Save abrarShariar/d752cd35c6b23f0177b9 to your computer and use it in GitHub Desktop.
View list of all directories and files in the mentioned location
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<dirent.h> | |
#include<cstdio> | |
using namespace std; | |
//Shows all the subdirectories and files in mentioned location | |
int main(){ | |
const char *location="E:\\2nd_semester\\C++\\C++Phone\\Code\\music"; | |
DIR *dir; | |
struct dirent *ent; | |
if ((dir = opendir (location)) != NULL) { | |
/* print all the files and directories within directory */ | |
while ((ent = readdir (dir)) != NULL) { | |
printf ("%s\n", ent->d_name); | |
} | |
closedir (dir); | |
} else { | |
/* could not open directory */ | |
perror (""); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment