How do I give the path name to the compiler?
Here is a portion of the code that I have written:
ifstream file;
file.open("test.txt");
I have test.txt in my computer but when I try writing the contents of this file to standard output using cout, there is nothing dispalyed. I suspect that the file is not found by the compiler.
You will want to check if it opened successfully. Also note that unless you provide the directory path, it will have to be in the same directory as the executable.
1 2 3 4 5 6 7
ifstream file;
file.open("test.txt");
if (file)
// file was opened successfully