My intention is to select a text file from the text / directory, but when I select it, I get the error.
ifstream Archivo;
system("clear");
cout << "Elige el archivo que quieres leer" << endl;
system("cd texto/ && ls --color");
cout << "Abrir: ";
cin >> archivo_elegir;
Archivo.open(archivo_elegir);
if(Archivo.fail()){
cout << "Error al abrir el archivo." << endl;
exit(1);
}
else{
cout << "OK";
}
Archivo.close();
If I had the txt in the same executable directory and changed the line
system("cd text/ && ls --color");
for
system("ls --color");
the program works.