<?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[printf große Zahlen Tausender-Trennpunkte?]]></title><description><![CDATA[<p>Hallo zusammen.<br />
Kann man mit printf oder std::cout eine große Zahl durch Trennpunkte bei Tausendern formatiert ausgeben lassen?</p>
<p>Ein geeigneter Modifikator dafür konnte ich nicht finden und meine Lösungen sind hoffnungslos verbuggt.</p>
<p>Vielen Dank für jegliche Hilfe<br />
Johannes Schneider-</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/308623/printf-große-zahlen-tausender-trennpunkte</link><generator>RSS for Node</generator><lastBuildDate>Wed, 05 Aug 2026 18:05:35 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/308623.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 30 Sep 2012 18:18:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to printf große Zahlen Tausender-Trennpunkte? on Sun, 30 Sep 2012 18:18:54 GMT]]></title><description><![CDATA[<p>Hallo zusammen.<br />
Kann man mit printf oder std::cout eine große Zahl durch Trennpunkte bei Tausendern formatiert ausgeben lassen?</p>
<p>Ein geeigneter Modifikator dafür konnte ich nicht finden und meine Lösungen sind hoffnungslos verbuggt.</p>
<p>Vielen Dank für jegliche Hilfe<br />
Johannes Schneider-</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2255860</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2255860</guid><dc:creator><![CDATA[Johannes Schneider]]></dc:creator><pubDate>Sun, 30 Sep 2012 18:18:54 GMT</pubDate></item><item><title><![CDATA[Reply to printf große Zahlen Tausender-Trennpunkte? on Sun, 30 Sep 2012 18:25:30 GMT]]></title><description><![CDATA[<p>Wenn du c++ benutzt benutze bitte std::cout.<br />
Ichweiß nicht ob std::cout eine derartige Funktion besitzt, jedoch kann man sie sehr leicht mittels std::string lösen(einfach immer 3 zahlen von hinten abzählen und einen Punkt einfügen)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2255862</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2255862</guid><dc:creator><![CDATA[Namenloser324]]></dc:creator><pubDate>Sun, 30 Sep 2012 18:25:30 GMT</pubDate></item><item><title><![CDATA[Reply to printf große Zahlen Tausender-Trennpunkte? on Sun, 30 Sep 2012 18:26:37 GMT]]></title><description><![CDATA[<p>ok ich versuchs mal und poste min Ergebnis. Hat jemand noch nen Kommentar zu dem Thema?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2255863</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2255863</guid><dc:creator><![CDATA[Johannes Schneider]]></dc:creator><pubDate>Sun, 30 Sep 2012 18:26:37 GMT</pubDate></item><item><title><![CDATA[Reply to printf große Zahlen Tausender-Trennpunkte? on Sun, 30 Sep 2012 19:32:40 GMT]]></title><description><![CDATA[<p>Johannes Schneider schrieb:</p>
<blockquote>
<p>Hat jemand noch nen Kommentar zu dem Thema?</p>
</blockquote>
<p>Hallo Johannes,</p>
<p>das ganze ist ein wenig tricky. Die Default-Einstellung ist, dass keine Tausender-Trenner benutzt werden. Mit der Überladung der '<a href="http://www.cplusplus.com/reference/std/locale/numpunct/" rel="nofollow">numeric punctuation facet</a>' geht's:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;locale&gt;

class TausenderPunkt : public std::numpunct&lt; char &gt;
{
protected:
    char_type do_thousands_sep() const 
    {
        return '.';
    }
    std::string do_grouping() const
    {
        return &quot;\003&quot;;
    }
};

int main()
{
    using namespace std;
    cout.imbue( locale( cout.getloc(), new TausenderPunkt ) );
    cout &lt;&lt; int(5.2E+6) &lt;&lt; endl;
    return 0;
}
</code></pre>
<p>Ausgabe wäre:</p>
<pre><code>5.200.000
</code></pre>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2255883</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2255883</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Sun, 30 Sep 2012 19:32:40 GMT</pubDate></item><item><title><![CDATA[Reply to printf große Zahlen Tausender-Trennpunkte? on Sun, 30 Sep 2012 19:37:06 GMT]]></title><description><![CDATA[<p>Was macht denn do_grouping?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2255886</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2255886</guid><dc:creator><![CDATA[Kellerautomat]]></dc:creator><pubDate>Sun, 30 Sep 2012 19:37:06 GMT</pubDate></item><item><title><![CDATA[Reply to printf große Zahlen Tausender-Trennpunkte? on Sun, 30 Sep 2012 19:45:49 GMT]]></title><description><![CDATA[<p>Kellerautomat schrieb:</p>
<blockquote>
<p>Was macht denn do_grouping?</p>
</blockquote>
<p><a href="http://www.cplusplus.com/reference/std/locale/numpunct/do_grouping/" rel="nofollow">http://www.cplusplus.com/reference/std/locale/numpunct/do_grouping/</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2255888</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2255888</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Sun, 30 Sep 2012 19:45:49 GMT</pubDate></item><item><title><![CDATA[Reply to printf große Zahlen Tausender-Trennpunkte? on Sun, 30 Sep 2012 19:58:30 GMT]]></title><description><![CDATA[<p>Hallo Werner,</p>
<p>Ich dachte mir bereits dass das mit Templates geht aber mir war klar dass die Lösung mein Können überschreiten würde.</p>
<p>Von daher: vielen Dank!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2255892</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2255892</guid><dc:creator><![CDATA[Johannes Schneider]]></dc:creator><pubDate>Sun, 30 Sep 2012 19:58:30 GMT</pubDate></item><item><title><![CDATA[Reply to printf große Zahlen Tausender-Trennpunkte? on Sun, 30 Sep 2012 20:01:15 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>Kellerautomat schrieb:</p>
<blockquote>
<p>Was macht denn do_grouping?</p>
</blockquote>
<p><a href="http://www.cplusplus.com/reference/std/locale/numpunct/do_grouping/" rel="nofollow">http://www.cplusplus.com/reference/std/locale/numpunct/do_grouping/</a></p>
</blockquote>
<p>LOL, wer hat denn das designt? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2255894</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2255894</guid><dc:creator><![CDATA[Kellerautomat]]></dc:creator><pubDate>Sun, 30 Sep 2012 20:01:15 GMT</pubDate></item><item><title><![CDATA[Reply to printf große Zahlen Tausender-Trennpunkte? on Sun, 30 Sep 2012 20:19:46 GMT]]></title><description><![CDATA[<p>Kellerautomat schrieb:</p>
<blockquote>
<p>SeppJ schrieb:</p>
<blockquote>
<p>Kellerautomat schrieb:</p>
<blockquote>
<p>Was macht denn do_grouping?</p>
</blockquote>
<p><a href="http://www.cplusplus.com/reference/std/locale/numpunct/do_grouping/" rel="nofollow">http://www.cplusplus.com/reference/std/locale/numpunct/do_grouping/</a></p>
</blockquote>
<p>LOL, wer hat denn das designt? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
</blockquote>
<p>Das war wohl jemand, der sich überlegt hat, wie man auch die Zahlen in Nepal korrekt mit Tausendertrenner schreiben kann. <a href="http://www.amazon.com/Standard-IOStreams-Locales-Programmers-Reference/dp/0201183951" rel="nofollow">Lt. Frau Langer</a> schreiben die dort z.B. 10.20.300 für 1Million-20Tausend-300Hundert. Wie hättest Du's gemacht?</p>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2255898</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2255898</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Sun, 30 Sep 2012 20:19:46 GMT</pubDate></item><item><title><![CDATA[Reply to printf große Zahlen Tausender-Trennpunkte? on Sun, 30 Sep 2012 20:26:33 GMT]]></title><description><![CDATA[<p>Für printf gehts mit POSIX und dem Apostroph</p>
<pre><code class="language-cpp">#include &lt;stdio.h&gt;
#include &lt;locale.h&gt;
int main()
{
  setlocale(LC_NUMERIC,&quot;german&quot;);
  printf(&quot;%'lu&quot;,1111111111UL);
  return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2255900</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2255900</guid><dc:creator><![CDATA[Wutz]]></dc:creator><pubDate>Sun, 30 Sep 2012 20:26:33 GMT</pubDate></item><item><title><![CDATA[Reply to printf große Zahlen Tausender-Trennpunkte? on Mon, 01 Oct 2012 05:57:49 GMT]]></title><description><![CDATA[<p>Werner Salomon schrieb:</p>
<blockquote>
<p>Wie hättest Du's gemacht?</p>
</blockquote>
<p>Z.B. vector&lt;unsigned&gt;, aber ein string ist so ziemlich der ungeeignetste Typ ueberhaupt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2255939</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2255939</guid><dc:creator><![CDATA[Kellerautomat]]></dc:creator><pubDate>Mon, 01 Oct 2012 05:57:49 GMT</pubDate></item><item><title><![CDATA[Reply to printf große Zahlen Tausender-Trennpunkte? on Mon, 01 Oct 2012 10:08:00 GMT]]></title><description><![CDATA[<p>Kellerautomat schrieb:</p>
<blockquote>
<p>Werner Salomon schrieb:</p>
<blockquote>
<p>Wie hättest Du's gemacht?</p>
</blockquote>
<p>Z.B. vector&lt;unsigned&gt;,</p>
</blockquote>
<p>Gab's damals noch nicht.</p>
<blockquote>
<p>aber ein string ist so ziemlich der ungeeignetste Typ ueberhaupt.</p>
</blockquote>
<p>Ein String ist doch praktisch ein vector&lt;char&gt;.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2256024</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2256024</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 01 Oct 2012 10:08:00 GMT</pubDate></item><item><title><![CDATA[Reply to printf große Zahlen Tausender-Trennpunkte? on Mon, 01 Oct 2012 10:14:32 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>Ein String ist doch praktisch ein vector&lt;char&gt;.</p>
</blockquote>
<p>Nicht nur, dass char dafuer total unpassend ist (wenns wenigstens signed/unsigned char waere), finde ich, dass ein string mehr ist als ein blosses char[]. Er kann einfach viel mehr, das passt zu einer Zahlengruppierung einfach nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2256029</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2256029</guid><dc:creator><![CDATA[Kellerautomat]]></dc:creator><pubDate>Mon, 01 Oct 2012 10:14:32 GMT</pubDate></item><item><title><![CDATA[Reply to printf große Zahlen Tausender-Trennpunkte? on Mon, 01 Oct 2012 10:42:24 GMT]]></title><description><![CDATA[<p><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="😮"
    /> Ist für dich ein vector&lt;unsigned&gt; das gleiche wie unsigned[]?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2256044</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2256044</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 01 Oct 2012 10:42:24 GMT</pubDate></item><item><title><![CDATA[Reply to printf große Zahlen Tausender-Trennpunkte? on Mon, 01 Oct 2012 11:24:59 GMT]]></title><description><![CDATA[<p>Wieso, er hat doch das Gegenteil gesagt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2256054</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2256054</guid><dc:creator><![CDATA[Eisflamme]]></dc:creator><pubDate>Mon, 01 Oct 2012 11:24:59 GMT</pubDate></item><item><title><![CDATA[Reply to printf große Zahlen Tausender-Trennpunkte? on Mon, 01 Oct 2012 12:02:29 GMT]]></title><description><![CDATA[<p>Eisflamme schrieb:</p>
<blockquote>
<p>Wieso, er hat doch das Gegenteil gesagt?</p>
</blockquote>
<p>Ich habe gesagt, ein String ist praktisch vector&lt;char&gt;, er erwidert, ein String ist viel mehr als char[]. Also char[] == vector&lt;char&gt;?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2256066</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2256066</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 01 Oct 2012 12:02:29 GMT</pubDate></item><item><title><![CDATA[Reply to printf große Zahlen Tausender-Trennpunkte? on Mon, 01 Oct 2012 12:44:05 GMT]]></title><description><![CDATA[<p>Ah, jetzt versteh ich.</p>
<p>Nunja, er sieht für die Fragestellung aber offensichtlich einen char[] als vector&lt;char&gt; an, weil ein vector&lt;char&gt;/char[] eher &quot;viele Zeichen ohne semantischen Zusammenhang&quot; sind und ein string eben doch der Gesamtkette eher eine Bedeutung zuweist. So verstehe ich das, unterschreiben tue ich aber ohne Anwalt gar nichts.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2256075</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2256075</guid><dc:creator><![CDATA[Eisflamme]]></dc:creator><pubDate>Mon, 01 Oct 2012 12:44:05 GMT</pubDate></item><item><title><![CDATA[Reply to printf große Zahlen Tausender-Trennpunkte? on Mon, 01 Oct 2012 21:06:25 GMT]]></title><description><![CDATA[<p>Ein vector ist fuer mich ein verbessertes T[], ja. Und Eisflamme hat's richtig verstanden, ein string gibt dem ganzen eine semantische Bedeutung.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2256269</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2256269</guid><dc:creator><![CDATA[Kellerautomat]]></dc:creator><pubDate>Mon, 01 Oct 2012 21:06:25 GMT</pubDate></item></channel></rss>