I am making a virtual machine and i need to open a directory (progs/Input) that holds all the assembler .s files. Once the directory is open i need to get the names of all the files in the directory so i can open them. Once the .s file is open i modify the name by erasing the 's' and adding a 'o'. The problem i am having is that it seems i cannot use fstream to open a directory and then grab the names of files inside, the file seems to not be opening and my exit(20) triggers. I know i can use
system("ls *.s > progs/Input");
and that will give me all the file names inside the directory but i want to know if there is a way to get my code working (the code above is some code my teacher gave the class) or if my way will never work. The code that follows are the relevant bits of my code.
Either you use what the teacher provides (Input would be a file not a directory) or you system dependant functions or external libraries such as boost.