I am trying to make dir command .I have a problem in my code.it print name of all subdirectories and files but it does not print all files of all subdirectories only print one subdirectories files.
I want to print all file and all subdirectory files
Void list(const char *path)
{
DIR *d,*d1;
struct dirent *dir;
chdir(path);
d=opendir(".");
if(d)
while((dir=readdir(d)))
if(!strcmp(".",dir->d_name))
continue;
if(!strcmp("..",dir->d_name))
continue;
else
{
printf("%s\n",dir->d_name);
d1=opendir(dir->d_name);
if(d1)
{
list(dir->d_name);
}
}
closedir(d);
}
int main()
{
char path[]="c:\\";
list(path);
}