<?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 mit string]]></title><description><![CDATA[<p>hallo,</p>
<p>ich versuche eine zahl immer durch 10 zu teilen und sie dann als string einzulesen, jedoch wird die zahl nach 6 oder 7 schritten als 1 eingelesen obwohl mir cout was anderes sagt. was mache ich falsch? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<pre><code>// programm2.cc
#include &lt;sstream&gt; 
#include &lt;string&gt; 
#include &lt;iostream&gt;
int main ()
{
    double x(1);
    std::string S(&quot;0.001&quot;);
    std::string u(&quot;0.1&quot;);
    int I(1);
    std::cout.precision( 17 );
    while(I!=20)
    {
                I=I+1;
                x=x*0.1;
                std::ostringstream Str2;
                Str2 &lt;&lt; x+1;
                std::string S(Str2.str());
                std::cout &lt;&lt; &quot;S(nachher)=&quot; &lt;&lt; S &lt;&lt; std::endl;
                int L=S.length();
                std::cout &lt;&lt; &quot;Lange=&quot; &lt;&lt; S.length() &lt;&lt; &quot; x+1=&quot; &lt;&lt; x+1 &lt;&lt; &quot;     I=&quot; &lt;&lt; I &lt;&lt; &quot; L=&quot; &lt;&lt; L &lt;&lt; std::endl &lt;&lt; std::endl;
                }
    std::cout &lt;&lt; &quot;Beendet &quot; &lt;&lt; &quot;x+1=&quot; &lt;&lt; x+1 &lt;&lt; u &lt;&lt; std::endl;

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/253290/problem-mit-string</link><generator>RSS for Node</generator><lastBuildDate>Sun, 13 Sep 2026 22:27:30 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/253290.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 31 Oct 2009 09:23:05 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem mit string on Sat, 31 Oct 2009 09:23:05 GMT]]></title><description><![CDATA[<p>hallo,</p>
<p>ich versuche eine zahl immer durch 10 zu teilen und sie dann als string einzulesen, jedoch wird die zahl nach 6 oder 7 schritten als 1 eingelesen obwohl mir cout was anderes sagt. was mache ich falsch? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<pre><code>// programm2.cc
#include &lt;sstream&gt; 
#include &lt;string&gt; 
#include &lt;iostream&gt;
int main ()
{
    double x(1);
    std::string S(&quot;0.001&quot;);
    std::string u(&quot;0.1&quot;);
    int I(1);
    std::cout.precision( 17 );
    while(I!=20)
    {
                I=I+1;
                x=x*0.1;
                std::ostringstream Str2;
                Str2 &lt;&lt; x+1;
                std::string S(Str2.str());
                std::cout &lt;&lt; &quot;S(nachher)=&quot; &lt;&lt; S &lt;&lt; std::endl;
                int L=S.length();
                std::cout &lt;&lt; &quot;Lange=&quot; &lt;&lt; S.length() &lt;&lt; &quot; x+1=&quot; &lt;&lt; x+1 &lt;&lt; &quot;     I=&quot; &lt;&lt; I &lt;&lt; &quot; L=&quot; &lt;&lt; L &lt;&lt; std::endl &lt;&lt; std::endl;
                }
    std::cout &lt;&lt; &quot;Beendet &quot; &lt;&lt; &quot;x+1=&quot; &lt;&lt; x+1 &lt;&lt; u &lt;&lt; std::endl;

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1801079</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1801079</guid><dc:creator><![CDATA[cppnewb]]></dc:creator><pubDate>Sat, 31 Oct 2009 09:23:05 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit string on Sat, 31 Oct 2009 09:40:15 GMT]]></title><description><![CDATA[<p>Du brauchst den <code>.precision</code> -Aufruf auch auf <code>Str2</code> bevor Du x+1 in den Stringstream reinschreibst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1801083</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1801083</guid><dc:creator><![CDATA[Sebastian Pizer]]></dc:creator><pubDate>Sat, 31 Oct 2009 09:40:15 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit string on Sat, 31 Oct 2009 09:52:43 GMT]]></title><description><![CDATA[<p>wie füge ich den ein? ich versteh was du meinst, kanns aber nicht umsetzen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":/"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1801086</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1801086</guid><dc:creator><![CDATA[cppnewb]]></dc:creator><pubDate>Sat, 31 Oct 2009 09:52:43 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit string on Sat, 31 Oct 2009 14:04:12 GMT]]></title><description><![CDATA[<p>TGGC schrieb:</p>
<blockquote>
<p>cppnewb schrieb:</p>
<blockquote>
<p>wie füge ich den ein? ich versteh was du meinst, kanns aber nicht umsetzen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":/"
      alt="😕"
    /></p>
</blockquote>
<p>In das *.cpp eintippen. f'`8k</p>
<p>Gruß, TGGC (<a href="http://www.gamestar.de/index.cfm?pid=819&amp;pk=12279" rel="nofollow">Was Gamestar sagt...</a>)</p>
</blockquote>
<p>schon klar, aber was? was muss ich for .precision schreiben? mit cout klappts nicht...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1801168</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1801168</guid><dc:creator><![CDATA[cppnewb]]></dc:creator><pubDate>Sat, 31 Oct 2009 14:04:12 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit string on Sat, 31 Oct 2009 14:29:42 GMT]]></title><description><![CDATA[<p>cppnewb schrieb:</p>
<blockquote>
<p>TGGC schrieb:</p>
<blockquote>
<p>cppnewb schrieb:</p>
<blockquote>
<p>wie füge ich den ein? ich versteh was du meinst, kanns aber nicht umsetzen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":/"
      alt="😕"
    /></p>
</blockquote>
<p>In das *.cpp eintippen. f'`8k</p>
<p>Gruß, TGGC (<a href="http://www.gamestar.de/index.cfm?pid=819&amp;pk=12279" rel="nofollow">Was Gamestar sagt...</a>)</p>
</blockquote>
<p>schon klar, aber was? was muss ich for .precision schreiben? mit cout klappts nicht...</p>
</blockquote>
<p>doch, es klappt mit cout.<br />
rtfm: <a href="http://www.cplusplus.com/reference/iostream/ios_base/precision/" rel="nofollow">http://www.cplusplus.com/reference/iostream/ios_base/precision/</a></p>
<p>bb</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1801187</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1801187</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Sat, 31 Oct 2009 14:29:42 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit string on Sat, 31 Oct 2009 14:51:28 GMT]]></title><description><![CDATA[<pre><code>// programm2.cc
#include &lt;sstream&gt; 
#include &lt;string&gt; 
#include &lt;iostream&gt;
#include &lt;iomanip&gt;
#include&lt;ios&gt;
int main ()
{
    double x(1);
    std::string S(&quot;0.001&quot;);
    std::string u(&quot;0.1&quot;);
    int I(1);
    std::cout.precision( 20 );
    std::setprecision(20);
    while(I!=20)
    {
                I=I+1;
                x=x*0.1;
                std::setprecision(20);
                std::cout.precision(20);
                std::ostringstream Str2;
                Str2 &lt;&lt; x+1 &lt;&lt; std::setprecision(20);
                std::string S(Str2.str());
                int L=S.length();
                if(x+1==1){
                          std::cout &lt;&lt; &quot;Fertig! mit x=&quot; &lt;&lt; x &lt;&lt; std::endl;
                          }

                std::cout &lt;&lt; &quot;S(nachher)=&quot; &lt;&lt; S &lt;&lt; std::endl;
                std::cout &lt;&lt; &quot;Lange=&quot; &lt;&lt; S.length() &lt;&lt; &quot; x+1=&quot; &lt;&lt; x+1 &lt;&lt; &quot;     I=&quot; &lt;&lt; I &lt;&lt; &quot; L=&quot; &lt;&lt; L &lt;&lt; std::endl &lt;&lt; std::endl;
                }
    std::cout &lt;&lt; &quot;Beendet &quot; &lt;&lt; &quot;x+1=&quot; &lt;&lt; x+1 &lt;&lt; std::endl;

}
</code></pre>
<p>nö klappt immer noch nicht. nach dem 7. durchlauf spuckt er mir als Länge des strings 1 aus...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1801196</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1801196</guid><dc:creator><![CDATA[cppnewb]]></dc:creator><pubDate>Sat, 31 Oct 2009 14:51:28 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit string on Sat, 31 Oct 2009 15:29:30 GMT]]></title><description><![CDATA[<p>xD<br />
rtfm!!!!!</p>
<pre><code class="language-cpp">#include &lt;sstream&gt;
#include &lt;string&gt;
#include &lt;iostream&gt;
#include &lt;iomanip&gt;

int main()
{
    double x = 1;
    std::cout.precision(20);

	for(int i = 1; i != 30; ++i)
    {
        x /= 10;
        if(x == 0)
			break;

        std::ostringstream ss;
        ss &lt;&lt; std::setprecision(20) &lt;&lt; x+1;
        std::string S(ss.str());

        std::cout &lt;&lt;
			&quot;S =    \t&quot; &lt;&lt; S &lt;&lt; std::endl &lt;&lt;
			&quot;\tLaenge=\t&quot; &lt;&lt; S.length() &lt;&lt; std::endl &lt;&lt;
			&quot;\tx+1 = \t&quot; &lt;&lt; x+1 &lt;&lt; std::endl &lt;&lt;
			&quot;\ti =   \t&quot; &lt;&lt; i &lt;&lt; std::endl &lt;&lt;
			std::endl &lt;&lt;
			std::endl;
	}
    std::cout &lt;&lt; &quot;Beendet &quot; &lt;&lt; &quot;x+1=&quot; &lt;&lt; x+1 &lt;&lt; std::endl;
}
</code></pre>
<p>geht nicht?</p>
<p>bb</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1801209</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1801209</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Sat, 31 Oct 2009 15:29:30 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit string on Sat, 31 Oct 2009 16:28:30 GMT]]></title><description><![CDATA[<p>nicht aufregen, bin mit der syntax von c++ noch nicht vertraut :p<br />
danke klappt jetzt <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="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1801261</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1801261</guid><dc:creator><![CDATA[cppnewb]]></dc:creator><pubDate>Sat, 31 Oct 2009 16:28:30 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit string on Sat, 31 Oct 2009 16:39:29 GMT]]></title><description><![CDATA[<p>cppnewb schrieb:</p>
<blockquote>
<p>nicht aufregen, bin mit der syntax von c++ noch nicht vertraut</p>
</blockquote>
<p>da waren noch ganz andere schnitzer drin als nur syntaktische...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1801265</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1801265</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Sat, 31 Oct 2009 16:39:29 GMT</pubDate></item></channel></rss>