title: Read .txt files from C++ program in Xcode
body: <p>I have been struggling on getting my C++ program to read my .txt file from Xcode.
  I even tried putting the .txt file in the same directory of my Xcode C++ program but it won't read from it successfully. I am trying to fill the dnaData array with all the nucleotides in the file, so I only have to read it once and then I can just operate on that array. Below is just a part of my code that handles the file. The idea of the whole program is to write a program that reads an input file (dna.txt) containing DNA sequences, analyzes the input in various ways, and outputs several files containing various results. The maximum number of nucleotides (see Table 1) in the input file will be 50,000.
  Any suggestions please?</p>
  
  <pre><code>#include &lt;fstream&gt;
  #include &lt;cstdlib&gt;
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;sstream&gt;
  using namespace std;
  
  const int MAX_DNA = 50000;
  
  // Global DNA array. Once read from a file, it is
  // stored here for any subsequent function to use
  char dnaData[MAX_DNA];
  
  int readFromDNAFile(string fileName)
  {
  int returnValue = 0;
  
  ifstream inStream;
  inStream.open(fileName.c_str());
  
      if (inStream.fail())
      {
          cout &lt;&lt; "Input file opening failed.\n";
          exit(1);
      }
  
      if (inStream.good())
      {
          char nucleotide;
          int counter = 0;
          while ( inStream &gt;&gt; nucleotide )
          {
              dnaData[counter] = nucleotide;
              counter++;
          }
          returnValue = counter;
      }
  
      inStream.close();
      return returnValue;
      cout &lt;&lt; "Read file completed" &lt;&lt; endl;
  
  } // end of readFromDNAfile function
  </code></pre>