My C program reads a text file. When I put it into Xcode it fails. What's happening?
Make sure that the input.txt file is not in the project folders, but in the same folder as the compiled program. You can find this by right selecting the executable under the 'Products' folder in the left pane of Xcode and selecting "Show in finder" and then move your .txt file there, and run it again.
File open failure! reading from a file, c++, xcode
From the tag you put to the question, I think you are using Xcode, right? You need to know where does Xcode output the executable, and your People.txt file needs to be put under the same folder as the executable. In Xcode, goto
Xcode > Preference > Locations
The path shown under "Derived Data", is where Xcode put executable. It's typically ~/Library/Developer/Xcode/DerivedData.
There you will probably find a lot of folders of your projects. Go into the folder corresponds to this project and goto Build/Products/Debug, then you will find your executable. What you can do is put your People.txt there.
OR your can add the full path of your "People.txt" file to your inputFile.open() method.
Related Topics
Initializer List Not Working with Vector in Visual Studio 2012
How to Check Whether Multiple Variables Are Equal to the Same Value
C++ Function Callbacks: Cannot Convert from a Member Function to a Function Signature
Why Use Precompiled Headers (C/C++)
Convert Float to Std::String in C++
Erasing Using Backspace Control Character
What Does 'Auto && E' Do in Range-Based For-Loops
How to Allocate a 2D Array of Pointers in C++
Valgrind Memory Leak Errors When Using Pthread_Create
How to Cast a Derived Class to a Private Base Class, Using C-Style Cast
Variadic Template in VS 2012 (Visual C++ November 2012 Ctp)
Compiling a Simple Parser with Boost.Spirit
How to Check That an Element Is in a Std::Set
Call Base Class Method from Derived Class Object
Should I Copy an Std::Function or How to Always Take a Reference to It