a way to read file line to line , but give problem
<p>I want to read file line to line , here is code :</p>

<pre><code>map&lt;int,string&gt;WordList ; //int is the key, string the returnad value
int GetWordList(char* file)
{
    WordList.clear();
    char getch;
    int wordindex=-1;
    string tempstring="";
    ifstream myFile(file);
    while (!myFile.eof())
    {
         myFile.get(getch);
         if (getch=='\r') continue; // skipping '\r' characters
         if (getch == '\n' || myFile.eof() )
         {
               WordList[++wordindex]=tempstring;
               tempstring="";
         }else  tempstring+=getch;
    }
    return wordindex; //returns the maximum index
}
</code></pre>

<p>I have called</p>

<pre><code> int totalStudents = GetWordList("C:\Students.txt");
</code></pre>

<p>I have three line in that file ,
but when I run program , it will not exit from while loop and also WordList is always 0 , </p>
