C++ getline(cin, str) giving me extra line
<p>I am a newbie in c++. I am using Cygwin and eclipse in window 7 and I am trying to write a program to just ask user to input a string and just print it out. I have the code below.</p>

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

int main() {
    string mystr;
    cout &lt;&lt; "What's your name? ";
    getline (cin, mystr, '\n');
    cout &lt;&lt; "Hello " &lt;&lt; mystr &lt;&lt; ".\n";
    return 0;
}
</code></pre>

<p>I also try:</p>

<pre><code>getline(cin, mystr);
</code></pre>

<p>They both gave me a out put like below.</p>

<p>output:</p>

<pre><code>What's your name? nick
Hello nick
.
</code></pre>

<p>Why is the full stop goes to the next line?
Can someone tell what happen and teach me how to fix it.</p>
