<?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 zu double Konvertierung via stringstreams]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich habe folgendes Problem:<br />
ich habe eine Datei geparst und die Informationen befinden sich nun in einem std::vector<a href="std::string" rel="nofollow">std::string</a>.</p>
<p>In einem Element des Vektors befindet sich eine Kommazahl (Dezimalstellen durch . abgetrennt) als std::string abgelegt - also zB ist der Inhalt &quot;54.000 |&quot; (die Zahl befindet sich immer zu Beginn des strings) - Diese Zahl soll nun in ein double, um mit ihr sinnvoll arbeiten zu können.<br />
Also hatte ich folgendes vor:</p>
<pre><code class="language-cpp">double CWTemp = 0.0;
std::stringstream ss( v[i].substr(0, v[i].find_first_not_of(&quot;0123456789.-&quot;) );
ss &gt;&gt; CWTemp;
</code></pre>
<p>das Problem ist, dass in CWTemp aber weiterhin 0 drinsteht und nicht 54.<br />
Gebe ich den stringstream per cout auf der Konsole aus, kommt aber korrekterweise die Ausgabe:<br />
54.000<br />
Habt ihr eine Idee, wo der Fehler liegt?</p>
<p>Compiler ist g++ (gcc 4.2.1)</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/220386/problem-mit-string-zu-double-konvertierung-via-stringstreams</link><generator>RSS for Node</generator><lastBuildDate>Wed, 07 Oct 2026 08:04:26 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/220386.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 15 Aug 2008 11:50:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem mit string zu double Konvertierung via stringstreams on Fri, 15 Aug 2008 11:50:43 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich habe folgendes Problem:<br />
ich habe eine Datei geparst und die Informationen befinden sich nun in einem std::vector<a href="std::string" rel="nofollow">std::string</a>.</p>
<p>In einem Element des Vektors befindet sich eine Kommazahl (Dezimalstellen durch . abgetrennt) als std::string abgelegt - also zB ist der Inhalt &quot;54.000 |&quot; (die Zahl befindet sich immer zu Beginn des strings) - Diese Zahl soll nun in ein double, um mit ihr sinnvoll arbeiten zu können.<br />
Also hatte ich folgendes vor:</p>
<pre><code class="language-cpp">double CWTemp = 0.0;
std::stringstream ss( v[i].substr(0, v[i].find_first_not_of(&quot;0123456789.-&quot;) );
ss &gt;&gt; CWTemp;
</code></pre>
<p>das Problem ist, dass in CWTemp aber weiterhin 0 drinsteht und nicht 54.<br />
Gebe ich den stringstream per cout auf der Konsole aus, kommt aber korrekterweise die Ausgabe:<br />
54.000<br />
Habt ihr eine Idee, wo der Fehler liegt?</p>
<p>Compiler ist g++ (gcc 4.2.1)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1565381</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1565381</guid><dc:creator><![CDATA[dblstrrtslbd]]></dc:creator><pubDate>Fri, 15 Aug 2008 11:50:43 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit string zu double Konvertierung via stringstreams on Fri, 15 Aug 2008 11:51:46 GMT]]></title><description><![CDATA[<p>sry Klammer vergessen, muss natürlich so aussehen</p>
<pre><code class="language-cpp">double CWTemp = 0.0;
std::stringstream ss( v[i].substr(0, v[i].find_first_not_of(&quot;0123456789.-&quot;) ) );
ss &gt;&gt; CWTemp;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1565383</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1565383</guid><dc:creator><![CDATA[dblstrrtslbd]]></dc:creator><pubDate>Fri, 15 Aug 2008 11:51:46 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit string zu double Konvertierung via stringstreams on Fri, 15 Aug 2008 12:46:51 GMT]]></title><description><![CDATA[<p>Versuchs mal so:</p>
<pre><code class="language-cpp">double CWTemp = 0.0;
std::stringstream ss(v[i]);
ss &gt;&gt; CWTemp;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1565437</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1565437</guid><dc:creator><![CDATA[Airdamn]]></dc:creator><pubDate>Fri, 15 Aug 2008 12:46:51 GMT</pubDate></item></channel></rss>