Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old Jan 24, 2010, 04:13 PM   #1
aprofetto
macrumors 6502a
 
aprofetto's Avatar
 
Join Date: Dec 2008
Location: Hamilton, Ontario
Trouble reading a .txt file with Xcode C++

Hey guys, the following code simply won't work for me?

The file is there, I have tried both the way it currently is, and also using the full file path, neither seem to work.

Code:
// reading a text file
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main () {
  string line;
  ifstream myfile ("example.txt");
  if (myfile.is_open())
  {
    while (! myfile.eof() )
    {
      getline (myfile,line);
      cout << line << endl;
    }
    myfile.close();
  }

  else cout << "Unable to open file"; 

  return 0;
}
Any ideas? Thanks guys.

EDIT: It keeps saying Program received signal: "SIGABRT".
aprofetto is offline   0 Reply With Quote

 
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Applescript - formatting a txt file using write dam316 Mac Applications and Mac App Store 0 May 4, 2014 05:26 PM
Resolved: Trouble reading a .txt file in Xcode with C++ rayonix Mac Programming 2 Jan 4, 2014 04:03 PM
Xcode 4.6. Can't open .txt file thrill4rishabh Mac Programming 6 May 28, 2013 01:22 PM
Apple Hardware Test had trouble reading env file nfear24 MacBook Pro 3 Jan 3, 2013 05:02 PM
Resolved: Applescript: List/txt.file question h1068 Mac Programming 5 Jul 3, 2012 06:30 PM

Forum Jump

All times are GMT -5. The time now is 04:09 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC