PDA

View Full Version : read/write .txt on Xcode C++




z7tjxd45
Dec 6, 2011, 06:34 PM
ifstream fin;
fin.open("/Users/Mike/Desktop/data.txt");
if (fin.fail())
{
cerr <<"Unable to open data.txt" << endl;
exit(1);


Is what I have. and Xcode tells me "Error from Debugger. The program being debugged is not being run. I also get an error in terminal.

data.txt is on the desktop. What am I missing here?



kainjow
Dec 8, 2011, 09:37 PM
It works for me. Are you sure that file exists?

ppc_michael
Dec 8, 2011, 11:39 PM
Are you using #include <fstream>?

lights
Dec 13, 2011, 02:34 PM
ifstream fin;
fin.open("/Users/Mike/Desktop/data.txt");
if (fin.fail())
{
cerr <<"Unable to open data.txt" << endl;
exit(1);


Is what I have. and Xcode tells me "Error from Debugger. The program being debugged is not being run. I also get an error in terminal.

data.txt is on the desktop. What am I missing here?

I had problems before, what i did was put go into preferences to look for the derived files and put the data text inside the debug folder.