title: C++ How to get substring from ifstream and getline()
body: <p>What is printed to the console:</p>
  
  <pre><code>START(0,0)
  GOAL(0,2)
  ooox
  xxoo
  ooox
  </code></pre>
  
  <p>I want to be able to obtain the substring of the START and GOAL points, not including the brackets just the coordinate pair. I would also want to store them as variables as well since I want to add validation whether the START or GOAL points are out of bounds from the grid.</p>
  
  <p>I am trying to make an application to traverse the 2D grid, where the 'x' represents the blocked paths and 'o' represents unblocked. </p>
  
  <p>The starting point is always from the bottom left of the grid as represented below:</p>
  
  <pre><code>(0,2)(1,2)(2,2)(3,2)
  (0,1)(1,1)(2,1)(3,1)
  (0,0)(1,0)(2,0)(3,0)
  </code></pre>
  
  <p>I have tried using .substr() method with the start and end points of where I would like to store the values but it does not print out anything in the console.</p>
  
  <pre><code>void Grid::loadFromFile(const std::string&amp; filename){
      std::string line;
      std::ifstream file(filename);
      file.open(filename);
      // Reads the file line by line and outputs each line
      while(std::getline(file, line)) {
          std::cout &lt;&lt; line &lt;&lt; std::endl;
      }
  
          std::string startPoint, goalPoint;
  
          startPoint = line.substr(6,3);
          std::cout &lt;&lt; startPoint &lt;&lt; std::endl;
  
          file.close();
      }
  </code></pre>
  
  <p>I expect <code>std::cout &lt;&lt; startPoint &lt;&lt; std::endl;</code> to print the substring into the console but it just reads the file and prints whatever is in it, and nothing else.</p>