title: Failed to read .txt file in C++
body: <p>I have a .txt file and I tried using the absolute path "C:\Users\(full path)\A3Data" and static paths (shown in code):</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;sstream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  int main()
  {
      string line;
      ifstream MyReadFile("A3Data.txt");
  
      if(MyReadFile.is_open()) //checks whether file is being opened
      {
          while (getline(MyReadFile, line)) //uses getline to get the string values from the .txt file to read line by line
          {
          cout &lt;&lt; line &lt;&lt; '\n';
          }
          MyReadFile.close();
      }
      else if (MyReadFile.fail())
      {
          cout &lt;&lt; "A3Data.txt failed to open" &lt;&lt; endl;
      }
  
      return 0;
  }
  </code></pre>
  
  <p>Expected output:
  (contents in <code>A3Data.txt</code>)</p>
  
  <p>Actual Output:  </p>
  
  <pre><code>"A3Data.txt failed to open"
  </code></pre>
  
  <p>Double backslashing the absolute path e.g. <code>C:\\Users\\(full path)\\A3Data.txt</code> gives me the error too.</p>
  
  <p>Changing the filepaths and ifstream-ing it to the different path also shows me the error.</p>
  
  <p>When i tried to read my file from cmd, I cd'ed it to the full path and typed in the text file name. I could open &amp; read it properly. Hence I feel that the w.r.x are accessible to me and I have rights to the file.</p>
  
  <p>UPDATE:</p>
  
  <p>I have figured out my issue. Thank you all for the answers!</p>