<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Problem: float in wstringstream]]></title><description><![CDATA[<p>Hallo Zusammen</p>
<p>Entschuldigt wenn ich mit nem alten Problem komme, aber ich hab schon ne Weile rumprobiert und gesucht, in C++ Referenz und Forum, aber das Problem bleibt.</p>
<p>Habe einen wstringstream und gebe darauf eine float aus, mit Angabe der Kommastellen, danach soll eine Einheit ausgegeben werden.<br />
Nun wird die Zeile aber beim Punkt abgeschnitten.<br />
Also hier mein Codestück:</p>
<pre><code class="language-cpp">#include &lt;sstream&gt;
#include &lt;iomanip&gt;
//...
    std::wstringstream text;
    float bla = 123.456789;
    switch( msg ) 
    {
    case WM_PAINT:
        text &lt;&lt; std::setprecision(6) &lt;&lt; std::fixed &lt;&lt; bla &lt;&lt; &quot; Blas&quot; ;
        if( hDC = BeginPaint( hWnd_, &amp;ps ) ) 
        {
            TextOut( hDC, 0, 0, text.str().c_str(), sizeof( text.str().c_str() ) );	
            EndPaint( hWnd_, &amp;ps );
        }
</code></pre>
<p>Ausgabe: 123.</p>
<p>Ich hatte erst ewig Probleme mit Unicode / wchar_t / LPCWSTR Konvertierung, und nun das. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /><br />
Wer kann mir Helfen bitte?</p>
<p>Vielen Dank im Voraus <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /><br />
______</p>
<p>[edit]<br />
Lösung: statt sizeof( text.str().c_str() ) musste ich text.str().length angeben für die Länge des Strings.<br />
Aber warum? Die beiden Funktionen sollten doch das gleiche Ergebniss haben, oder seh ich das falsch?<br />
[/edit]</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/149200/problem-float-in-wstringstream</link><generator>RSS for Node</generator><lastBuildDate>Sat, 05 Sep 2026 05:42:12 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/149200.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 03 Jun 2006 12:07:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem: float in wstringstream on Sat, 03 Jun 2006 12:27:43 GMT]]></title><description><![CDATA[<p>Hallo Zusammen</p>
<p>Entschuldigt wenn ich mit nem alten Problem komme, aber ich hab schon ne Weile rumprobiert und gesucht, in C++ Referenz und Forum, aber das Problem bleibt.</p>
<p>Habe einen wstringstream und gebe darauf eine float aus, mit Angabe der Kommastellen, danach soll eine Einheit ausgegeben werden.<br />
Nun wird die Zeile aber beim Punkt abgeschnitten.<br />
Also hier mein Codestück:</p>
<pre><code class="language-cpp">#include &lt;sstream&gt;
#include &lt;iomanip&gt;
//...
    std::wstringstream text;
    float bla = 123.456789;
    switch( msg ) 
    {
    case WM_PAINT:
        text &lt;&lt; std::setprecision(6) &lt;&lt; std::fixed &lt;&lt; bla &lt;&lt; &quot; Blas&quot; ;
        if( hDC = BeginPaint( hWnd_, &amp;ps ) ) 
        {
            TextOut( hDC, 0, 0, text.str().c_str(), sizeof( text.str().c_str() ) );	
            EndPaint( hWnd_, &amp;ps );
        }
</code></pre>
<p>Ausgabe: 123.</p>
<p>Ich hatte erst ewig Probleme mit Unicode / wchar_t / LPCWSTR Konvertierung, und nun das. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /><br />
Wer kann mir Helfen bitte?</p>
<p>Vielen Dank im Voraus <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /><br />
______</p>
<p>[edit]<br />
Lösung: statt sizeof( text.str().c_str() ) musste ich text.str().length angeben für die Länge des Strings.<br />
Aber warum? Die beiden Funktionen sollten doch das gleiche Ergebniss haben, oder seh ich das falsch?<br />
[/edit]</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1070629</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070629</guid><dc:creator><![CDATA[Buena Vista]]></dc:creator><pubDate>Sat, 03 Jun 2006 12:27:43 GMT</pubDate></item><item><title><![CDATA[Reply to Problem: float in wstringstream on Sat, 03 Jun 2006 12:39:42 GMT]]></title><description><![CDATA[<p>Nein, sizeof(text.str().c_str()) liefert Dir die Größe eines konstanten char-Zeigers, und das ist üblicherweise 4 oder 8 (64-bit) Byte.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1070652</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070652</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Sat, 03 Jun 2006 12:39:42 GMT</pubDate></item><item><title><![CDATA[Reply to Problem: float in wstringstream on Sat, 03 Jun 2006 12:51:55 GMT]]></title><description><![CDATA[<p>*schlafausdenaugenreib* <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /></p>
<p>Ja stimmt, ich depp.<br />
Danke, so geht es jetzt.</p>
<p>Hät noch die Frage, ob es für stringstreams eine Multidefinitions Variante gibt,<br />
wie das _T(x) oder TCHAR Makro? (VC2005)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1070662</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070662</guid><dc:creator><![CDATA[Buena Vista]]></dc:creator><pubDate>Sat, 03 Jun 2006 12:51:55 GMT</pubDate></item><item><title><![CDATA[Reply to Problem: float in wstringstream on Sat, 03 Jun 2006 12:58:13 GMT]]></title><description><![CDATA[<p>nein musste selbst machen</p>
<pre><code class="language-cpp">std::basic_stringstream&lt;TCHAR&gt; ss;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1070665</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070665</guid><dc:creator><![CDATA[ss]]></dc:creator><pubDate>Sat, 03 Jun 2006 12:58:13 GMT</pubDate></item><item><title><![CDATA[Reply to Problem: float in wstringstream on Sat, 03 Jun 2006 14:47:36 GMT]]></title><description><![CDATA[<p>Ok, Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1070733</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070733</guid><dc:creator><![CDATA[Buena Vista]]></dc:creator><pubDate>Sat, 03 Jun 2006 14:47:36 GMT</pubDate></item></channel></rss>