I am carrying out a program which asks me to go through several files that are in a specific folder (they are like 500 files). I have already managed to read a file using fstream
, but I would like to see if there is any way to access the folder to access the names and read it one by one.
This is the code I'm using to read a file:
#include<stdlib.h>
#include<string.h>
#include<fstream>
#include<iostream>
using namespace std;
void lectura ();
int main(){
lectura();
system("pause");
return 0;
}
void lectura(){
ifstream archivo;
string texto;
archivo.open("003.html",ios::in); //abre el rachivo
if(archivo.fail()){
cout<<" No se pudo abrir el archivo";
exit(1);
}
while(!archivo.eof()){
getline(archivo,texto);
cout<<texto<<endl;
}
archivo.close();
}