<?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[array von pair benutzen]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte folgendes implementieren:</p>
<p>[cpp][/code]<br />
#include &lt;string&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;fstream&gt;<br />
#include &lt;utility&gt;</p>
<p>using namespace std;</p>
<p>int main(){</p>
<p>pair&lt;string, string&gt; meinarray[1];</p>
<p>ofstream myFile(&quot;c:/out.txt&quot;);<br />
// Creates an ofstream object named myFile</p>
<p>meinarray[0].first = (&quot;Hallo&quot;);<br />
meinarray[0].second = (&quot;Christoph&quot;);<br />
meinarray[1].first = (&quot;Du bist&quot;);<br />
meinarray[1].second = (&quot;super&quot;);</p>
<p>if (! myFile) // Always test file open<br />
{<br />
cout &lt;&lt; &quot;Error opening output file&quot; &lt;&lt; endl;<br />
return -1;<br />
}</p>
<p>myFile &lt;&lt; meinarray[0].first &lt;&lt; &quot;\t&quot;;<br />
myFile &lt;&lt; meinarray[0].second &lt;&lt; endl;</p>
<p>myFile &lt;&lt; meinarray[1].first &lt;&lt; &quot;\t&quot;;<br />
myFile &lt;&lt; meinarray[1].second &lt;&lt; endl;</p>
<p>myFile.close();<br />
}</p>
<p>leider funktioniert das so nicht. Wo liegt der Fehler?<br />
Wenn ich nur das erste Feld meinarray[0]. belege und abfrage funktioniert es!</p>
<p>Ich möchte Wertepaare mit pair in einem array speichern um das dann in eine datei zu schreiben und auch wieder auslesen zu können.</p>
<p>Gruss<br />
Christoph<br />
(email: <a href="mailto:christ.richter@gmx.de" rel="nofollow">christ.richter@gmx.de</a>)</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/143530/array-von-pair-benutzen</link><generator>RSS for Node</generator><lastBuildDate>Wed, 02 Sep 2026 05:54:02 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/143530.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 09 Apr 2006 14:06:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to array von pair benutzen on Sun, 09 Apr 2006 14:06:11 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte folgendes implementieren:</p>
<p>[cpp][/code]<br />
#include &lt;string&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;fstream&gt;<br />
#include &lt;utility&gt;</p>
<p>using namespace std;</p>
<p>int main(){</p>
<p>pair&lt;string, string&gt; meinarray[1];</p>
<p>ofstream myFile(&quot;c:/out.txt&quot;);<br />
// Creates an ofstream object named myFile</p>
<p>meinarray[0].first = (&quot;Hallo&quot;);<br />
meinarray[0].second = (&quot;Christoph&quot;);<br />
meinarray[1].first = (&quot;Du bist&quot;);<br />
meinarray[1].second = (&quot;super&quot;);</p>
<p>if (! myFile) // Always test file open<br />
{<br />
cout &lt;&lt; &quot;Error opening output file&quot; &lt;&lt; endl;<br />
return -1;<br />
}</p>
<p>myFile &lt;&lt; meinarray[0].first &lt;&lt; &quot;\t&quot;;<br />
myFile &lt;&lt; meinarray[0].second &lt;&lt; endl;</p>
<p>myFile &lt;&lt; meinarray[1].first &lt;&lt; &quot;\t&quot;;<br />
myFile &lt;&lt; meinarray[1].second &lt;&lt; endl;</p>
<p>myFile.close();<br />
}</p>
<p>leider funktioniert das so nicht. Wo liegt der Fehler?<br />
Wenn ich nur das erste Feld meinarray[0]. belege und abfrage funktioniert es!</p>
<p>Ich möchte Wertepaare mit pair in einem array speichern um das dann in eine datei zu schreiben und auch wieder auslesen zu können.</p>
<p>Gruss<br />
Christoph<br />
(email: <a href="mailto:christ.richter@gmx.de" rel="nofollow">christ.richter@gmx.de</a>)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1033799</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1033799</guid><dc:creator><![CDATA[christ.richter]]></dc:creator><pubDate>Sun, 09 Apr 2006 14:06:11 GMT</pubDate></item><item><title><![CDATA[Reply to array von pair benutzen on Sun, 09 Apr 2006 14:14:04 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Wenn du zwei Stellen in deinem Feld willst, musst du das auch ansagen:</p>
<pre><code class="language-cpp">std::pair&lt;std::string, std::string&gt; Pairs[2];
</code></pre>
<p>und nicht Pairs[1];</p>
<p>Dann kannst du auf Pairs[0] und Pairs[1] zugreifen.</p>
<p>chrische</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1033811</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1033811</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 09 Apr 2006 14:14:04 GMT</pubDate></item><item><title><![CDATA[Reply to array von pair benutzen on Sun, 09 Apr 2006 14:19:17 GMT]]></title><description><![CDATA[<p>danke,</p>
<p>so funktionierts.</p>
<p>Aber warum? ein array fängt doch bei index 0 an.<br />
Demnach bin ich davon ausgegangen das meinarray[1]<br />
index 0 und index 1 besitzt.</p>
<p>Denke ich da falsch?</p>
<p>Gruss<br />
Christoph</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1033818</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1033818</guid><dc:creator><![CDATA[christ.richter]]></dc:creator><pubDate>Sun, 09 Apr 2006 14:19:17 GMT</pubDate></item><item><title><![CDATA[Reply to array von pair benutzen on Sun, 09 Apr 2006 14:21:28 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Du musst erstmal sagen wieviele Stellen du willst: also zum Beispiel 5. Dann kanst du auf 5 Stellen zugreifen (0,1,2,3,4).</p>
<p>chrische</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1033822</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1033822</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 09 Apr 2006 14:21:28 GMT</pubDate></item><item><title><![CDATA[Reply to array von pair benutzen on Sun, 09 Apr 2006 14:34:49 GMT]]></title><description><![CDATA[<p>danke dir!</p>
<p>Christoph</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1033848</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1033848</guid><dc:creator><![CDATA[christ.richter]]></dc:creator><pubDate>Sun, 09 Apr 2006 14:34:49 GMT</pubDate></item></channel></rss>