title: Processing a file line by line and parsing the line to get separate variables
body: <p>So I'm new to C++ and I am trying to take a file that looks like this:</p>
  
  <pre><code>0 A
  1 B
  2 C
  3 D
  4 E
  </code></pre>
  
  <p>I need to process this file line by line obviously and then in each line I need to take the two numbers from the line and put them in a map where the number is an ID # for a Node with a name that is a string so 0 would be the key for node A in my map.</p>
  
  <p>I think I have the line by line part down but even that is a little rocky.</p>
  
  <p>Here is what I have:</p>
  
  <pre><code>bool read_index(map&lt;long, string&gt; &amp;index_map, string file_name)
  {
      //create a file stream for the file to be read
      ifstream index_file(file_name);
  
      //if file doesn't open then return false
      if(! index_file.is_open())
          return false;
  
      string line;
      //read file
      while(! index_file.eof())
      {
          getline(index_file,line);
          stringstream ss(line);
          while(ss)
          {
              //process line?
          }
      }
  
      //file read
      return true;
  }
  </code></pre>