<?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[C Array in Stl Vector speichern]]></title><description><![CDATA[<p>Hallo liebe Community,</p>
<p>wie kann man ein C Array in einem Stl Vector speichern?</p>
<p>Beispielcode: (funktioniert leider nicht)</p>
<pre><code class="language-cpp">//Include

typedef int ARR [10];
ARR arr = {1,2,3,4,5,6,7,8,9,0};
vector&lt;ARR&gt; vect;

int main () {
   vect.push(arr);
   for (int i=0;i&lt;10;++i)
      cout &lt;&lt; vect[0][i] &lt;&lt; endl;
}
</code></pre>
<p>Hoffe ihr könnt mir helfen.</p>
<p><strong>PS:</strong> Also ich will schon ein C Array im Vector speichern und keinen anderen Vectotr!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/254097/c-array-in-stl-vector-speichern</link><generator>RSS for Node</generator><lastBuildDate>Sun, 13 Sep 2026 03:38:31 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/254097.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 11 Nov 2009 15:42:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to C Array in Stl Vector speichern on Wed, 11 Nov 2009 15:42:04 GMT]]></title><description><![CDATA[<p>Hallo liebe Community,</p>
<p>wie kann man ein C Array in einem Stl Vector speichern?</p>
<p>Beispielcode: (funktioniert leider nicht)</p>
<pre><code class="language-cpp">//Include

typedef int ARR [10];
ARR arr = {1,2,3,4,5,6,7,8,9,0};
vector&lt;ARR&gt; vect;

int main () {
   vect.push(arr);
   for (int i=0;i&lt;10;++i)
      cout &lt;&lt; vect[0][i] &lt;&lt; endl;
}
</code></pre>
<p>Hoffe ihr könnt mir helfen.</p>
<p><strong>PS:</strong> Also ich will schon ein C Array im Vector speichern und keinen anderen Vectotr!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1806563</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1806563</guid><dc:creator><![CDATA[ProgrammierGeselle]]></dc:creator><pubDate>Wed, 11 Nov 2009 15:42:04 GMT</pubDate></item><item><title><![CDATA[Reply to C Array in Stl Vector speichern on Wed, 11 Nov 2009 15:48:33 GMT]]></title><description><![CDATA[<p>Mach doch einfach eine Schleife.</p>
<pre><code class="language-cpp">for (int i=0;i&lt;10;++i) {
  vect.push_back(arr[i]);
}
</code></pre>
<p>Der vector muss dann natürlich auch vom Typ int sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1806568</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1806568</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Wed, 11 Nov 2009 15:48:33 GMT</pubDate></item><item><title><![CDATA[Reply to C Array in Stl Vector speichern on Wed, 11 Nov 2009 15:50:10 GMT]]></title><description><![CDATA[<p>Ich möchte mehrere Arrays drin speichern...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1806569</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1806569</guid><dc:creator><![CDATA[ProgrammierGeselle]]></dc:creator><pubDate>Wed, 11 Nov 2009 15:50:10 GMT</pubDate></item><item><title><![CDATA[Reply to C Array in Stl Vector speichern on Wed, 11 Nov 2009 15:53:32 GMT]]></title><description><![CDATA[<p>Arrays sind weder kopier- noch vergleichbar, also nein, geht nicht. Workaround:</p>
<pre><code class="language-cpp">struct ARR
{
    int var1;
    int var2;
    int var3;

    ...

    int var10;
}

std::vector&lt;ARR&gt; myVector;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1806571</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1806571</guid><dc:creator><![CDATA[Icematix]]></dc:creator><pubDate>Wed, 11 Nov 2009 15:53:32 GMT</pubDate></item><item><title><![CDATA[Reply to C Array in Stl Vector speichern on Wed, 11 Nov 2009 15:56:20 GMT]]></title><description><![CDATA[<p>Erzähl am besten mal genauer, welchen Hintergrund das Ganze hat, was du vorhast. Vielleicht findet man da ja eine grundsätzlich andere (aber vielleicht bessere) Lösung.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1806575</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1806575</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Wed, 11 Nov 2009 15:56:20 GMT</pubDate></item><item><title><![CDATA[Reply to C Array in Stl Vector speichern on Wed, 11 Nov 2009 15:59:04 GMT]]></title><description><![CDATA[<p>Dies ist eher eine, naja, schlechte Lösung, oder wie willst du die Variablen im struct iterieren um auf ihre Werte zuzugreifen.</p>
<p>Würde es mit</p>
<pre><code class="language-cpp">struct {
   int arr[10];
}
</code></pre>
<p>funktionieren?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1806577</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1806577</guid><dc:creator><![CDATA[ProgrammierGeselle]]></dc:creator><pubDate>Wed, 11 Nov 2009 15:59:04 GMT</pubDate></item><item><title><![CDATA[Reply to C Array in Stl Vector speichern on Wed, 11 Nov 2009 16:00:41 GMT]]></title><description><![CDATA[<p>ProgrammierGeselle schrieb:</p>
<blockquote>
<p>Dies ist eher eine, naja, schlechte Lösung, oder wie willst du die Variablen im struct iterieren um auf ihre Werte zuzugreifen.</p>
<p>Würde es mit</p>
<pre><code class="language-cpp">struct {
   int arr[10];
}
</code></pre>
<p>funktionieren?</p>
</blockquote>
<p>Ja.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1806579</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1806579</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Wed, 11 Nov 2009 16:00:41 GMT</pubDate></item><item><title><![CDATA[Reply to C Array in Stl Vector speichern on Wed, 11 Nov 2009 16:01:52 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/16702">@_matze</a>:<br />
Naja, bräuchte eigentlich einen Stl Container, also die Queue,<br />
mit der will ich meine BFS Funktion realisieren.<br />
Die Werte will ich in einem C Array speichern, da ich nur 1 Sekunde Zeit habe,<br />
um mit meinem Algo das Problem zu lösen und der Zugriff auf C Arrays schneller<br />
erfolgt als auf Vectors.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1806582</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1806582</guid><dc:creator><![CDATA[ProgrammierGeselle]]></dc:creator><pubDate>Wed, 11 Nov 2009 16:01:52 GMT</pubDate></item><item><title><![CDATA[Reply to C Array in Stl Vector speichern on Wed, 11 Nov 2009 16:16:50 GMT]]></title><description><![CDATA[<p>So habe ein Beispielcode entworfen der funktioniert,</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;vector&gt;

using namespace std;

// Array in einer Struktur definieren
struct ARR {
	int arr[10];
};

int main () {
	// Variablen deklarieren
	ARR cnt;
	vector&lt;ARR&gt; vect;
	// C Array in Struktur initialisieren
	for (int i=0;i&lt;10;++i)
		cnt.arr[i]=i;
	// Struktur in Vector einfügen
	vect.push_back(cnt);
	// Inhalt von Vector ausgeben
	for (int i=0;i&lt;vect.size();++i)
		for (int j=0;j&lt;10;++j)
			cout &lt;&lt; vect[i].arr[j] &lt;&lt; (j==9?'\n':' ');
	// Programm Ende
	cin.get();
	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1806593</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1806593</guid><dc:creator><![CDATA[ProgrammierGeselle]]></dc:creator><pubDate>Wed, 11 Nov 2009 16:16:50 GMT</pubDate></item><item><title><![CDATA[Reply to C Array in Stl Vector speichern on Wed, 11 Nov 2009 17:12:18 GMT]]></title><description><![CDATA[<p>Soll das mit mehreren verschieden langen Arrays funktionieren sein, wäre btw. folgendes möglich:</p>
<pre><code class="language-cpp">template &lt;unsigned int length&gt; struct ARR {
    int arr[length];
}; 

std::vector&lt;ARR&lt;10&gt; &gt; vecarr;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1806632</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1806632</guid><dc:creator><![CDATA[Paul Manns]]></dc:creator><pubDate>Wed, 11 Nov 2009 17:12:18 GMT</pubDate></item><item><title><![CDATA[Reply to C Array in Stl Vector speichern on Wed, 11 Nov 2009 20:00:32 GMT]]></title><description><![CDATA[<p>Der Unterschied zwischen std::vector und Array ist minimal, also von der Performance. Ich bezweifle heftig dass die STL für dein Vorhaben zu langsam ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1806713</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1806713</guid><dc:creator><![CDATA[Icematix]]></dc:creator><pubDate>Wed, 11 Nov 2009 20:00:32 GMT</pubDate></item><item><title><![CDATA[Reply to C Array in Stl Vector speichern on Wed, 11 Nov 2009 20:01:42 GMT]]></title><description><![CDATA[<p>ProgrammierGeselle schrieb:</p>
<blockquote>
<p>Die Werte will ich in einem C Array speichern, da ich nur 1 Sekunde Zeit habe,<br />
um mit meinem Algo das Problem zu lösen <strong>und der Zugriff auf C Arrays schneller<br />
erfolgt als auf Vectors.</strong></p>
</blockquote>
<p>Was den Zugriff betrifft, sind wohl beide ziemlich genau gleich schnel, sofern man allfällige Laufzeitprüfungen deaktiviert und im Release-Modus testet.</p>
<p>Unbestätigte Vermutungen dieser Art führen oft dazu, dass man eine schlechtere Variante wählt. Wenn du es wirklich genau wissen willst, messe nach. Aber sei dir bewusst, dass es in C++ keinen Grund gibt, weshalb Container langsamer sein müssen als Arrays (ganz speziell beim Wrapper <code>std::tr1::array</code> ).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1806714</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1806714</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Wed, 11 Nov 2009 20:01:42 GMT</pubDate></item></channel></rss>