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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
How to create and use input/output files with Xcode C++ hotglass Mac Programming 14 Feb 6, 2012 10:53 PM
Reading and writing files and storage locations xcode portreathbeach iPhone/iPad Programming 1 Apr 2, 2011 06:22 PM
Problem opening a *.txt file in Xcode Command Line Application Averello Mac Programming 2 Dec 23, 2009 08:46 AM
Can MacBook read chinese .txt files? Sasuke-chan MacBook 15 Nov 9, 2009 08:41 PM
Multiline txt file with Geektool robsilverii Mac Applications and Mac App Store 0 May 2, 2009 12:04 AM


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

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

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