IO stream

I am having issues opening a file in the same directory as the command line programme in mac. When I debug in xcode it finds the data. However when I run the unix executable file it cannot see the txt file in the same directory.

here is my code:

1
2
3
4
5
6
7
8
9
10
11
12
		
while(stop == false){

                ifstream input;
		input.open("[0][0].txt");

		if(!input.is_open()){
			input.close();
			cout << "File not opened, leaving loop\n";
			break;
		}
}


It always breaks out of the loop when not running in xcode.

If someone could point out where I have gone wrong that would be useful. I initially developed this under windows and it worked and am now trying to get it to work on mac.

Thanks
File paths are relative to the current working directory which doesn't have to be the same as the directory where the executable file is located.
Thank you.
Topic archived. No new replies allowed.