title: C++ GetUserName() returning username and gibberish
body: <p>I want to get the username of the current process. I am using the winapi standard <code>GetUsername</code> function like so:</p>
  
  <pre><code>TCHAR username[UNLEN + 1];
  DWORD size = UNLEN + 1;
  GetUserName((TCHAR*)username, &amp;size);
  </code></pre>
  
  <p>and printing it like this:</p>
  
  <pre><code>for(int i = 0; i &lt;= UNLEN; i++) if(isalpha(username[i])) cout &lt;&lt; (char)(username[i]);
  </code></pre>
  
  <p>but it outputs</p>
  
  <p>Nickiê╕♣■scm+♣■pα┬p♠■≡î■ └M♣■╧*■╔       ■♣ÿ(♣♣(♣♣♣♣    T♣@♣3♣■┐</p>
  
  <p><code>Nicki</code> is the username of the system I am testing on.
  I do not know what I am doing wrong. It compiles fine, and I am including</p>
  
  <pre><code>#include &lt;Windows.h&gt;
  #include &lt;Lmcons.h&gt;
  #include &lt;iostream&gt;
  #include &lt;ctype.h&gt;
  #include &lt;string&gt;
  </code></pre>
  
  <p>these headers.</p>
  
  <p>Can someone please help!</p>