A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

C++ Program to List and Display Files in Current Directory / Folder Using File Handling
Q:

C++ Program to List and Display Files in Current Directory / Folder Using File Handling

0

Explanation:-

 So in this problem, we have to print the all directory/folder and subdirectory and subfolder. We have to print only the name of all directory/folder and subdirectory and subfolder. using file handling in which our program is situated or our program is saved in the directory.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include<iostream>
#include<conio.h>
#include<dirent.h>
using namespace std;
main()
{
 int done, i=1;
 DIR *dir;
 dirent *pdir;
 cout<<"Press any key to list and view all the files in the current directory : \n";
 getch();
 dir=opendir(".");
 while(pdir=readdir(dir))
 {
 cout<<i<<"="<<pdir->d_name<<" \n";
 i++;
 }
 closedir(dir);
 return 0;
}

 

Output:

Press any key to list and view all the files in the current directory : 

1=main.cpp 

2=.. 

3=. 

4=a.out 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now