I have tried to open the particular file, but i didnt managed to open it, i wonder where is the file i supposed to save it at, in the debug folder or the current working directory. Why the program will skip this ----if(!myfile)-----
Please help me with some suggested source of problem.
void readTextFile(){
ifstream myfile;
bool check=false;
string line;
myfile.open ("fileList.txt",ios::in);
if(!myfile){
check = true;
if (myfile.is_open()) {
while (!myfile.eof()){
getline(myfile,line);
cout<<line;
//vector push creates a new element
}
}
}
else cout<<"\n unable to open file";
}
In windows:
How are you executing your .exe? In visual studio you can press CTRL+F5 to execute your program, but it won't use the configuration directory as the current directory.
If you call the .exe from the console without having the current directory as the root directory of the .exe, then it won't find the file there either.