<?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[streams formatieren]]></title><description><![CDATA[<p>Guten Morgen @all,</p>
<p>ich habe in der Vergangenheit so eine Art C mit Klassen verwendet. In der letzten Zeit habe ich mich (unter VS2012) mit STL angefreundet und habe angefangen einen Teil meiner Projekte anzupassen. Dabei bin ich über die Formatierung von printf und Co gestolpert.</p>
<p>Ich habe für die streams Formatfunktionen wie Width und Precision gefunden aber ganz so komfortabel wie ein klassischer Formatstring ist das nicht. Gibt es was vergleichbares für die iostreams?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/317357/streams-formatieren</link><generator>RSS for Node</generator><lastBuildDate>Mon, 27 Jul 2026 16:07:30 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/317357.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 06 Jun 2013 06:37:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to streams formatieren on Thu, 06 Jun 2013 06:37:27 GMT]]></title><description><![CDATA[<p>Guten Morgen @all,</p>
<p>ich habe in der Vergangenheit so eine Art C mit Klassen verwendet. In der letzten Zeit habe ich mich (unter VS2012) mit STL angefreundet und habe angefangen einen Teil meiner Projekte anzupassen. Dabei bin ich über die Formatierung von printf und Co gestolpert.</p>
<p>Ich habe für die streams Formatfunktionen wie Width und Precision gefunden aber ganz so komfortabel wie ein klassischer Formatstring ist das nicht. Gibt es was vergleichbares für die iostreams?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2328915</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2328915</guid><dc:creator><![CDATA[andreasgeorg]]></dc:creator><pubDate>Thu, 06 Jun 2013 06:37:27 GMT</pubDate></item><item><title><![CDATA[Reply to streams formatieren on Thu, 06 Jun 2013 06:54:01 GMT]]></title><description><![CDATA[<p>Du könntest mal einen Blick auf <a href="http://www.boost.org/doc/libs/1_53_0/libs/format" rel="nofollow">boost::Format</a> werfen. Dazu musst du allerdings die boost Bibliotheken installieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2328917</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2328917</guid><dc:creator><![CDATA[DocShoe]]></dc:creator><pubDate>Thu, 06 Jun 2013 06:54:01 GMT</pubDate></item><item><title><![CDATA[Reply to streams formatieren on Thu, 06 Jun 2013 06:55:21 GMT]]></title><description><![CDATA[<p>In der C++ Standard-Library selbst gibt es das nicht. Allerdings gibt es Libraries dafür, u.a. <a href="http://www.boost.org/libs/format" rel="nofollow">Boost.Format</a> und <a href="http://fastformat.sourceforge.net/" rel="nofollow">FastFormat</a>.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2328918</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2328918</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Thu, 06 Jun 2013 06:55:21 GMT</pubDate></item><item><title><![CDATA[Reply to streams formatieren on Thu, 06 Jun 2013 09:10:17 GMT]]></title><description><![CDATA[<p>Danke, ich werde mir die Boost Lib mal ansehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2328948</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2328948</guid><dc:creator><![CDATA[andreasgeorg]]></dc:creator><pubDate>Thu, 06 Jun 2013 09:10:17 GMT</pubDate></item><item><title><![CDATA[Reply to streams formatieren on Thu, 11 Jul 2013 05:08:55 GMT]]></title><description><![CDATA[<p>Da das hier in den alten Thread mit reinpasst ...</p>
<p>Noch mal eine Frage zur Ausgabe von Gleitkommazahlen. Ist es mit Boardmitteln der STL möglich, daß eine Gleitkommazahl mit n Nachkommastellen augegeben wird. Mir ist es mit precision bisher nur gelungen die Nachkommastellen zubegrenzen. Ich möchte aber das ggf. unnötige Stellen mit Nullen aufgefüllt werden.</p>
<p>z.B. 3.14 soll als 3.1400 ausgegeben werden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2338095</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2338095</guid><dc:creator><![CDATA[andreasgeorg]]></dc:creator><pubDate>Thu, 11 Jul 2013 05:08:55 GMT</pubDate></item><item><title><![CDATA[Reply to streams formatieren on Thu, 11 Jul 2013 05:13:01 GMT]]></title><description><![CDATA[<p>width und fill</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2338097</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2338097</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Thu, 11 Jul 2013 05:13:01 GMT</pubDate></item><item><title><![CDATA[Reply to streams formatieren on Thu, 11 Jul 2013 05:37:22 GMT]]></title><description><![CDATA[<p>Wenn immer genau X Nachkommastellen ausgegeben werden sollen,...</p>
<pre><code>float pi = 3.14f;
std::cout &lt;&lt; std::fixed &lt;&lt; std::setprecision(X) &lt;&lt; pi;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2338103</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2338103</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Thu, 11 Jul 2013 05:37:22 GMT</pubDate></item><item><title><![CDATA[Reply to streams formatieren on Thu, 11 Jul 2013 08:58:05 GMT]]></title><description><![CDATA[<p>Danke,</p>
<p>könnt Ihr mir noch erklären wo der Unterschied ist zwischen</p>
<pre><code>float pi = 3.14f;
std::ofstream ofs(&quot;vcf.txt&quot;);
ofs.precision(6);
ofs.setstate(std::ios::fixed)
ofs &lt;&lt; pi &lt;&lt; '\n';
ofs.close()
</code></pre>
<p>und</p>
<pre><code>float pi = 3.14f;
std::ofstream ofs(&quot;vcf.txt&quot;);
ofs &lt;&lt; std::fixed &lt;&lt; std::setprecision(6) &lt;&lt; pi &lt;&lt; '\n';
ofs.close()
</code></pre>
<p>Die erste Version gibt 3.14 aus und Sonne's Version wie gewünscht 3.140000.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2338141</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2338141</guid><dc:creator><![CDATA[andreasgeorg]]></dc:creator><pubDate>Thu, 11 Jul 2013 08:58:05 GMT</pubDate></item><item><title><![CDATA[Reply to streams formatieren on Thu, 11 Jul 2013 09:31:55 GMT]]></title><description><![CDATA[<p>Vor allem mal ist das erste falsch. Was nicht unbedingt den Unterschied zwischen deinen Ausgaben erklärt, weil das eigentlich gar nicht compiliert.</p>
<p>Du meinst sicherlich:</p>
<pre><code>ofs.setf(std::ios::fixed)
</code></pre>
<p>Damit kann und wird das auch wie gewünscht funktionieren.</p>
<p>Wieso muss ich eigentlich deine Frage für dich korrekt formulieren?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2338149</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2338149</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Thu, 11 Jul 2013 09:31:55 GMT</pubDate></item><item><title><![CDATA[Reply to streams formatieren on Thu, 11 Jul 2013 10:07:40 GMT]]></title><description><![CDATA[<p>Hallo SeppJ,</p>
<p>SeppJ schrieb:</p>
<blockquote>
<p>Vor allem mal ist das erste falsch. Was nicht unbedingt den Unterschied zwischen deinen Ausgaben erklärt, weil das eigentlich gar nicht compiliert.</p>
</blockquote>
<p>Mit VS2012 läßt sich das problemlos, compilieren.</p>
<p>SeppJ schrieb:</p>
<blockquote>
<p>Du meinst sicherlich:</p>
<pre><code>ofs.setf(std::ios::fixed)
</code></pre>
<p>Damit kann und wird das auch wie gewünscht funktionieren.</p>
</blockquote>
<p>Ja tut es, ich habs probiert. Ich hatte die falsche Funktion gewählt.</p>
<p>SeppJ schrieb:</p>
<blockquote>
<p>Wieso muss ich eigentlich deine Frage für dich korrekt formulieren?</p>
</blockquote>
<p>Hast Du ja nicht, Du hast die Frage einfach nur beantwortet und mir meinen Fehler gezeigt.</p>
<p>Mußt nicht immer so brummig sein <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2338158</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2338158</guid><dc:creator><![CDATA[andreasgeorg]]></dc:creator><pubDate>Thu, 11 Jul 2013 10:07:40 GMT</pubDate></item></channel></rss>