title: Reading strings and integers from .txt file and printing output as strings only
body: <p>I'm new to C++, and I'm trying to write a short C++ program that reads lines of
  text from a file, with each line containing one integer key and one alphanumeric string value (no embedded whitespace). The number of lines is not known in advance, (i.e., keep reading lines until end of file is reached). The program needs to use the 'std::map' data structure to store integers and strings read from input (and to associate integers with strings). The program then needs to output string values (but not integer values) to standard output, 1 per line, sorted by integer key values (smallest to largest). So, for example, suppose I have a text file called "data.txt" which contains the following three lines:</p>
  
  <p>10 dog<br>
  -50 horse<br>
  0 cat<br>
  -12 zebra<br>
  14 walrus  </p>
  
  <p>The output should then be:</p>
  
  <p>horse<br>
  zebra<br>
  cat<br>
  dog<br>
  walrus  </p>
  
  <p>I've pasted below the progress I've made so far on my C++ program:</p>
  
  <pre><code>#include &lt;fstream&gt;  
  #include &lt;iostream&gt;  
  #include &lt;map&gt;
  using namespace std;
  using std::map;
  int main () 
  {
  string name;
  signed int value;
  ifstream myfile ("data.txt");
  
  while (! myfile.eof() )
  {
  getline(myfile,name,'\n');
  myfile &gt;&gt; value &gt;&gt; name;
  cout &lt;&lt; name &lt;&lt; endl;
  }
  return 0;
  myfile.close();
  }
  </code></pre>
  
  <p>Unfortunately, this produces the following incorrect output:</p>
  
  <p>horse<br>
  cat<br>
  zebra<br>
  walrus  </p>
  
  <p>If anyone has any tips, hints, suggestions, etc. on changes and revisions
  I need to make to the program to get it to work as needed, can you please
  let me know? </p>
  
  <p>Thanks!</p>