reading file outside project folder

I am just starting to use files in C++ and want to know if there is a way to read a file outside the projects folder. I have one program that writes information to a file and I want to have a different program read the data, but the folder is in the first programs project folder. I don't want to move the file because I want to be able to add to it using the first program. Sorry if this doesn't make sense.
You should be able to refer to the file with a relative pathname, something like this:
char* filename = "../Proj2/file.txt";
The double dots go up a level. If you need to go up two levels, use "../../Proj2/whatever".
Last edited on
That worked. Thank you.
In case you're using Windows, note that the forward slashes will work anywhere.
It sure is a shame the shell doesn't allow you to specify paths with forward slashes. It'd make many of my tasks a little easier.
Topic archived. No new replies allowed.