<?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[string zerlegen nach double]]></title><description><![CDATA[<p>Heiho</p>
<p>ich hole aus einer liste ein string, der sieht zb so aus</p>
<pre><code class="language-cpp">&quot;12.13 - 14.4&quot;

//das moechte ich zerlegen zu

double a = 12;
double b = 13;
double c = 14.4
</code></pre>
<p>wie mach ich das am besten - geholt wird es als TCHAR</p>
<p>das hab ich bisher:</p>
<pre><code class="language-cpp">TCHAR str[13] = {'\0'};
TCHAR a[3] = {'\0'};
TCHAR b[3] = {'\0'};
TCHAR c[5] = {'\0'};
ListView_GetItemText(m_list, 1, 0, str, 100);
a[0] = str[0];
a[1] = str[1];
b[0] = str[3];
b[1] = str[4];
c[0] = str[8];
c[1] = str[9];
c[2] = str[10];
c[3] = str[11];
</code></pre>
<p>anders wuesste ichs bisher nicht</p>
<p>ich kann nu entweder versuchen das TCHAR nach double zu wandeln oder</p>
<pre><code class="language-cpp">std::wstring wstr(a);
</code></pre>
<p>und dann das wstring nach double - so oder so bekomm ich des nicht hin ?!</p>
<p>also die frage</p>
<p>1. wie kann ich eleganter zerteilen ? die positionen sind immer fest, auch die maximale groesse</p>
<p>(immer &quot;2.2 - 2.1&quot;)</p>
<p>2. wie kann ich TCHAR oder wstring nach double wandeln ?</p>
<p>danke schonmal</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/168928/string-zerlegen-nach-double</link><generator>RSS for Node</generator><lastBuildDate>Wed, 16 Sep 2026 13:57:39 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/168928.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 29 Dec 2006 18:41:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to string zerlegen nach double on Fri, 29 Dec 2006 18:41:54 GMT]]></title><description><![CDATA[<p>Heiho</p>
<p>ich hole aus einer liste ein string, der sieht zb so aus</p>
<pre><code class="language-cpp">&quot;12.13 - 14.4&quot;

//das moechte ich zerlegen zu

double a = 12;
double b = 13;
double c = 14.4
</code></pre>
<p>wie mach ich das am besten - geholt wird es als TCHAR</p>
<p>das hab ich bisher:</p>
<pre><code class="language-cpp">TCHAR str[13] = {'\0'};
TCHAR a[3] = {'\0'};
TCHAR b[3] = {'\0'};
TCHAR c[5] = {'\0'};
ListView_GetItemText(m_list, 1, 0, str, 100);
a[0] = str[0];
a[1] = str[1];
b[0] = str[3];
b[1] = str[4];
c[0] = str[8];
c[1] = str[9];
c[2] = str[10];
c[3] = str[11];
</code></pre>
<p>anders wuesste ichs bisher nicht</p>
<p>ich kann nu entweder versuchen das TCHAR nach double zu wandeln oder</p>
<pre><code class="language-cpp">std::wstring wstr(a);
</code></pre>
<p>und dann das wstring nach double - so oder so bekomm ich des nicht hin ?!</p>
<p>also die frage</p>
<p>1. wie kann ich eleganter zerteilen ? die positionen sind immer fest, auch die maximale groesse</p>
<p>(immer &quot;2.2 - 2.1&quot;)</p>
<p>2. wie kann ich TCHAR oder wstring nach double wandeln ?</p>
<p>danke schonmal</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1199599</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1199599</guid><dc:creator><![CDATA[EXDW]]></dc:creator><pubDate>Fri, 29 Dec 2006 18:41:54 GMT</pubDate></item><item><title><![CDATA[Reply to string zerlegen nach double on Fri, 29 Dec 2006 19:18:01 GMT]]></title><description><![CDATA[<p>Na such halt nach dem &quot;-&quot; und pack die beiden enden jeweils in nen string. Dann schieb alles in nen stringstream und hol dir nen double raus <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/1199614</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1199614</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Fri, 29 Dec 2006 19:18:01 GMT</pubDate></item><item><title><![CDATA[Reply to string zerlegen nach double on Fri, 29 Dec 2006 19:27:16 GMT]]></title><description><![CDATA[<p>(D)Evil schrieb:</p>
<blockquote>
<p>stringstream und hol dir nen double raus</p>
</blockquote>
<p>und wie geht das ?</p>
<p>das hab ich bisher und es funktioniert:</p>
<pre><code class="language-cpp">TCHAR str[13] = {'\0'};
TCHAR a[3] = {'\0'};
double da = 0;
TCHAR b[3] = {'\0'};
double db = 0;
TCHAR ab[6] = {'\0'};
double dab = 0;
TCHAR c[5] = {'\0'};
double dc = 0;
SecureZeroMemory(str, 20);
SecureZeroMemory(a, 3);
SecureZeroMemory(b, 3);
SecureZeroMemory(c, 5);
SecureZeroMemory(ab, 6);
for(int i=0; i&lt;ListView_GetItemCount(m_List); ++i){
    ListView_GetItemText(m_List, i, 0, str, 13);
    if(str[0] == _T(''))
        break;
    else{
        ab[0] = a[0] = str[0];
        ab[1] = a[1] = str[1];
        ab[2] = str[2];
        ab[3] = b[0] = str[3];
        ab[4] = b[1] = str[4];
        c[0] = str[8];
        c[1] = str[9];
        c[2] = str[10];
        c[3] = str[11];
        std::wstring wstr(a);
        da= _wtof(wstr.data());
        wstr=b;
        db= _wtof(wstr.data());
        wstr=ab;
        dab= _wtof(wstr.data());
        wstr=c;
        dc= _wtof(wstr.data());
        // da  = WW
        // db  = XX
        // dab = WW.XX
        // dc  = YY.Z
        // weitere operationen mit den double zahlen
    }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1199620</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1199620</guid><dc:creator><![CDATA[EXDW]]></dc:creator><pubDate>Fri, 29 Dec 2006 19:27:16 GMT</pubDate></item><item><title><![CDATA[Reply to string zerlegen nach double on Fri, 29 Dec 2006 21:40:14 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">bool show_data(std::string sData)
{
    if (pData == NULL)
        return false;
    std::string::size_type pos = sData.find(&quot; - &quot;, 0);
    if (pos == string::npos)
        return false;

    std::string::size_type pos2 = sData.find_first_of(&quot;.&quot;);
    if (pos2 == std::string::npos)
        return false;

    std::stringstream ss;
    double dData3 = 0.0;
    double dData1 = 0.0;
    double dData2 = 0.0;
    ss &lt;&lt; sData.substr(pos);
    ss &gt;&gt; dData3; // 14.4
    ss.clear();
    ss &lt;&lt; sData.substr(0, pos2);
    ss &gt;&gt; dData1; // 12
    ss.clear();
    ss &lt;&lt; sData.substr(pos2, pos - pos2);
    ss &gt;&gt; dData2; // 13
    return true;
}
</code></pre>
<p>So habs net getestet sondern einfach kurz nach <a href="http://www.cppreference.com" rel="nofollow">www.cppreference.com</a> zusammengesetzt ... wo ist das Problem?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1199693</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1199693</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Fri, 29 Dec 2006 21:40:14 GMT</pubDate></item><item><title><![CDATA[Reply to string zerlegen nach double on Fri, 29 Dec 2006 23:07:11 GMT]]></title><description><![CDATA[<p>.. ich finde Ihr denkt zu kompliziert <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>
<p>einfach auslesen:</p>
<pre><code class="language-cpp">TCHAR src[] = TEXT(&quot;12.13 - 14.4&quot;);
    double a,b,c;
    {
        int aInt;
        TCHAR z;
        std::basic_istringstream&lt; TCHAR &gt; buf( src );
        buf &gt;&gt; aInt &gt;&gt; z &gt;&gt; b &gt;&gt; z &gt;&gt; c;
        a = aInt;
    }
</code></pre>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1199715</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1199715</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Fri, 29 Dec 2006 23:07:11 GMT</pubDate></item></channel></rss>