I have been looking for this specific method of reading from files, but I could not seem to find anything useful.
What I'm actually trying to do is reading the given file path as a variable.
Example:
1 2 3 4 5 6 7 8
|
// code
string path;
cin >> path;
ifstream in(path);
while (in && !in.eof() && in.is_open()){
// code
}
//code
|
I don't know if that is actually possible, but I'm trying to give the user the possibility of choosing which file to read from, without the need of it to be positioned in the same folder, and without the need of editing the C++ code in order to get it working (or rename the files to those name).
Any help in this way is highly appreciated. Thanks.
PS: Or, if possible, the user to enter the file name, and the C++ program is set to look-up the whole hard drive for the specific file, and if found, open it. I know that might take a lot of time, but I'm interested in knowing if that is possible. Thanks again.