<?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 als Index-Wert]]></title><description><![CDATA[<p>Hi,</p>
<p>ich habe mal vor einiger Zeit was gelesen, kann mich aber nichtmehr entsinnen, wie das genau war:</p>
<p>Ich suche eine Container-Klasse, der ich z.B. einen String übergebe und dieser wird als Index verwendet und ich bekomme den diesem String zugeordneten anderen Wert zurück, vgl. Wörterbuch.</p>
<p>Bsp:</p>
<pre><code>string englisch;
string deutsch=&quot;Haus&quot;;
englisch=German2English(deutsch);
</code></pre>
<p>So war das meine ich zu benutzen.</p>
<p>Gruss, Martin</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/131503/string-als-index-wert</link><generator>RSS for Node</generator><lastBuildDate>Thu, 27 Aug 2026 05:02:29 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/131503.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 04 Jan 2006 00:15:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to String als Index-Wert on Wed, 04 Jan 2006 00:15:12 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich habe mal vor einiger Zeit was gelesen, kann mich aber nichtmehr entsinnen, wie das genau war:</p>
<p>Ich suche eine Container-Klasse, der ich z.B. einen String übergebe und dieser wird als Index verwendet und ich bekomme den diesem String zugeordneten anderen Wert zurück, vgl. Wörterbuch.</p>
<p>Bsp:</p>
<pre><code>string englisch;
string deutsch=&quot;Haus&quot;;
englisch=German2English(deutsch);
</code></pre>
<p>So war das meine ich zu benutzen.</p>
<p>Gruss, Martin</p>
]]></description><link>https://www.c-plusplus.net/forum/post/956222</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/956222</guid><dc:creator><![CDATA[Karl Blau]]></dc:creator><pubDate>Wed, 04 Jan 2006 00:15:12 GMT</pubDate></item><item><title><![CDATA[Reply to String als Index-Wert on Wed, 04 Jan 2006 00:32:46 GMT]]></title><description><![CDATA[<p>Hallo,<br />
Da wird wohl eine std::map das richtige sein. Schau dir diese am besten mal genauer an.</p>
<p>Beispiel:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;map&gt;
using namespace std;

int main()
{
    string s(&quot;&quot;);
    map&lt;string, string&gt; m;
    while(1)
    {
        cout &lt;&lt; &quot;please enter a unique key (q = quit): &quot;;
        cin &gt;&gt; s;
        if(s == &quot;q&quot;)
            break;
        if(m.count(s) &lt; 1)
        {
            cout &lt;&lt; &quot;\nthe key &quot; &lt;&lt; s &lt;&lt; &quot; doesn't exist yet, please enter a corresponding value: &quot;;
            string val;
            cin &gt;&gt; val;

            m[s] = val;

            cout &lt;&lt; &quot;key/value pair added\n&quot;;
        }
        else
            cout &lt;&lt; &quot;the corresponding value of &quot; &lt;&lt; s &lt;&lt; &quot; = &quot; &lt;&lt; m[s] &lt;&lt; endl;
    }
    return 0;
}
</code></pre>
<p>Gruß Caipi</p>
]]></description><link>https://www.c-plusplus.net/forum/post/956232</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/956232</guid><dc:creator><![CDATA[Caipi]]></dc:creator><pubDate>Wed, 04 Jan 2006 00:32:46 GMT</pubDate></item><item><title><![CDATA[Reply to String als Index-Wert on Wed, 04 Jan 2006 22:17:44 GMT]]></title><description><![CDATA[<p>Vielen Dank für den Tipp! Das war goldrichtig.<br />
Ich habe sowas direkt in mein aktuelles Projekt eingebaut.</p>
<p>Wie kann ich nun alle Einträge ausgeben? Ich habe in <a href="http://cppreference.com" rel="nofollow">cppreference.com</a> nachgelesen, das hat mir aber kaum weitergeholfen. Wie kann ich über alle Einträge iterieren und beide Strings ausgeben?</p>
<pre><code>std::map&lt;std::string,std::string&gt;::const_iterator it;
for(it=myMap.begin(); it!=myMap.end(); it++)
{
	os &lt;&lt; it-&gt;???;
}
</code></pre>
<p>Oder ganz anders? Hmm...</p>
<p>Gruss, Karl</p>
]]></description><link>https://www.c-plusplus.net/forum/post/957246</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/957246</guid><dc:creator><![CDATA[Karl Blau]]></dc:creator><pubDate>Wed, 04 Jan 2006 22:17:44 GMT</pubDate></item><item><title><![CDATA[Reply to String als Index-Wert on Wed, 04 Jan 2006 22:19:48 GMT]]></title><description><![CDATA[<p>first und second</p>
<p>MfG SideWinder</p>
]]></description><link>https://www.c-plusplus.net/forum/post/957249</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/957249</guid><dc:creator><![CDATA[SideWinder]]></dc:creator><pubDate>Wed, 04 Jan 2006 22:19:48 GMT</pubDate></item><item><title><![CDATA[Reply to String als Index-Wert on Wed, 04 Jan 2006 22:21:53 GMT]]></title><description><![CDATA[<p>Vielen Dank</p>
<p>Karl</p>
]]></description><link>https://www.c-plusplus.net/forum/post/957251</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/957251</guid><dc:creator><![CDATA[Karl Blau]]></dc:creator><pubDate>Wed, 04 Jan 2006 22:21:53 GMT</pubDate></item></channel></rss>