My string gets from the ifstream also "\n"
<p>This is my problem: I read some lines from a txt. This txt is like this:</p>

<pre><code>Ciao: 2000
Kulo: 5000
Aereo: 7000
</code></pre>

<p>ecc. I have to assign every word before(':') to a string and then to a map; and the numbers to a int and then to a map. The problem is that beginning from the second line, my string become ("\nKulo") ecc! I don't want this! What can I do?</p>

<p>This is the code:</p>

<pre><code>        #include &lt;iostream&gt;
        #include &lt;fstream&gt;
        #include &lt;string&gt;
        #include &lt;map&gt;
        using namespace std;

        int main()
        {
            map &lt;string, int&gt; record;
            string nome, input;
            int valore;
            ifstream file("punteggi.txt");

            while (file.good()) {
                getline(file, nome, ':');
        //        nome.erase(0,2); //Elimina lo spazio iniziale
                file &gt;&gt; valore;
                record[nome] = valore;
                cout &lt;&lt; nome;
            }
            file.close();

            cout &lt;&lt; "\nNome: ";
            cin &gt;&gt; input;
            cout &lt;&lt; input &lt;&lt; ": " &lt;&lt; record[input] &lt;&lt; "\n";

            cout &lt;&lt; "\n\n";
            return 0;
        }
</code></pre>
