title: Is there a way to get a complete string with spaces in c++?
body: <p>So, i have a piece of code (c++) that gets the users name (in windows) and with the retrieved string the code creates respective directories...</p>
  
  <pre><code>BOOL DirectoryExists(const char* dirName) {
  
      TCHAR nameu[UNLEN + 1];
      DWORD size = UNLEN + 1;
      if (GetUserName((TCHAR*)nameu, &amp;size))
      {
          TCHAR* t = nameu;
          wcout &lt;&lt; t;
          //_getch();
          std::string str;
          std::wstring wStr = t;
          str = std::string(wStr.begin(), wStr.end());
          usr = str;
  
          dir[0] = (std::string("C:\\Users\\") + str + "\\Documents\\Folder").c_str();
      }
  
      DWORD attribs = ::GetFileAttributesA(dirName);
      if (attribs == INVALID_FILE_ATTRIBUTES) {
          return false;
      }
      return (attribs &amp; FILE_ATTRIBUTE_DIRECTORY);
  }
  </code></pre>
  
  <p>here, the <code>GetUserName()</code> functions gets the user name and this piece of code works fine if the user name is just one straight string, but if the usr name had two parts split by space (eg: "example account"), then the code only takes the first part and leaves the 2nd part/name....</p>
  
  <p>how do i solve this ?</p>