<?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[Vector.Size gibt Vector.Capacity aus]]></title><description><![CDATA[<p>Hey! Hab nach eurem letzten verbesserungsvorschlag mich mal an die STL gesetzt und mich bei meinem Progrämmchen für vector entschieden. Ich gebe Produkte ein und möchte alle Produkte ausgeben lassen, die ich bisher eingegeben habe. Macht er auch. Aber auch noch mehr.</p>
<pre><code class="language-cpp">void ausgabe()
{
	for(int i = 0; i&lt;_name.size(); i++)
				{
					cout&lt;&lt;&quot;Produktname:   &quot;&lt;&lt;_name[i];
					cout&lt;&lt;&quot;\nMHD:           &quot;&lt;&lt;_mhd[i];
					cout&lt;&lt;&quot;. . . . . . . . . . . . . &quot;&lt;&lt;endl;
				}
}
</code></pre>
<p>Hier soll er bei zb zwei eingegebenen Produkten auch nur soviele ausgeben, wie auch belegt sind... Ich glaub der gibt mir die Capacity aus oder? Also er zeigt mir schön die Produkte an aber auch noch (bei 2 Produkten) 8 leere Felder an!</p>
<p>Hier mal mein kompletter Code: (bin anfänger <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>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;conio.h&gt;
#include &lt;vector&gt;
#include &lt;Windows.h&gt;
#include &lt;string&gt;

using namespace std;

//GLOBALE VARIABELN //
int aktion_in;
int zero = 10;
string
					name,
					mhd;
int anzahl;
//VECTOREN//

	vector&lt;string&gt; _name(zero);
	vector&lt;string&gt; _mhd(zero);
	vector&lt;int&gt; _anzahl(zero);

void start()
{
	cout&lt;&lt;&quot;Hallo! Bitte geben sie ihre gewünschte Aktion ein! \n [1] - Produkt hinzufügen \n [2] - Produkt entfernen&quot;&lt;&lt;endl;
	cin&gt;&gt;aktion_in;
	if(aktion_in == 1 || 2)
	{
				cout&lt;&lt;&quot;Anzahl einzugebener Produkte eingeben!&quot;&lt;&lt;endl;
				cin&gt;&gt;anzahl;
				for(int i = 0; i&lt;anzahl; i++)
				{
					string _name_,
								_mhd_;
						int _anzahl_;
					cout&lt;&lt;&quot;Name des Produktes eingeben!\n&quot;&lt;&lt;endl;
					cin&gt;&gt;_name_;
					_name[i] = _name_;
					cout&lt;&lt;&quot;MHD des Produktes eingeben!\n&quot;&lt;&lt;endl;
					cin&gt;&gt;_mhd_;
					_mhd[i] = _mhd_;

					_mhd.push_back(_mhd_);
				}

	}

}

void ausgabe()
{
	for(int i = 0; i&lt;_name.size(); i++)
				{
					cout&lt;&lt;&quot;Produktname:   &quot;&lt;&lt;_name[i];
					cout&lt;&lt;&quot;\nMHD:           &quot;&lt;&lt;_mhd[i];
					cout&lt;&lt;&quot;. . . . . . . . . . . . . &quot;&lt;&lt;endl;
				}
}

int main ()
{
	start();
	ausgabe();
	getch();
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/277189/vector-size-gibt-vector-capacity-aus</link><generator>RSS for Node</generator><lastBuildDate>Wed, 26 Aug 2026 01:43:38 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/277189.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 14 Nov 2010 15:39:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Vector.Size gibt Vector.Capacity aus on Sun, 14 Nov 2010 15:39:03 GMT]]></title><description><![CDATA[<p>Hey! Hab nach eurem letzten verbesserungsvorschlag mich mal an die STL gesetzt und mich bei meinem Progrämmchen für vector entschieden. Ich gebe Produkte ein und möchte alle Produkte ausgeben lassen, die ich bisher eingegeben habe. Macht er auch. Aber auch noch mehr.</p>
<pre><code class="language-cpp">void ausgabe()
{
	for(int i = 0; i&lt;_name.size(); i++)
				{
					cout&lt;&lt;&quot;Produktname:   &quot;&lt;&lt;_name[i];
					cout&lt;&lt;&quot;\nMHD:           &quot;&lt;&lt;_mhd[i];
					cout&lt;&lt;&quot;. . . . . . . . . . . . . &quot;&lt;&lt;endl;
				}
}
</code></pre>
<p>Hier soll er bei zb zwei eingegebenen Produkten auch nur soviele ausgeben, wie auch belegt sind... Ich glaub der gibt mir die Capacity aus oder? Also er zeigt mir schön die Produkte an aber auch noch (bei 2 Produkten) 8 leere Felder an!</p>
<p>Hier mal mein kompletter Code: (bin anfänger <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>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;conio.h&gt;
#include &lt;vector&gt;
#include &lt;Windows.h&gt;
#include &lt;string&gt;

using namespace std;

//GLOBALE VARIABELN //
int aktion_in;
int zero = 10;
string
					name,
					mhd;
int anzahl;
//VECTOREN//

	vector&lt;string&gt; _name(zero);
	vector&lt;string&gt; _mhd(zero);
	vector&lt;int&gt; _anzahl(zero);

void start()
{
	cout&lt;&lt;&quot;Hallo! Bitte geben sie ihre gewünschte Aktion ein! \n [1] - Produkt hinzufügen \n [2] - Produkt entfernen&quot;&lt;&lt;endl;
	cin&gt;&gt;aktion_in;
	if(aktion_in == 1 || 2)
	{
				cout&lt;&lt;&quot;Anzahl einzugebener Produkte eingeben!&quot;&lt;&lt;endl;
				cin&gt;&gt;anzahl;
				for(int i = 0; i&lt;anzahl; i++)
				{
					string _name_,
								_mhd_;
						int _anzahl_;
					cout&lt;&lt;&quot;Name des Produktes eingeben!\n&quot;&lt;&lt;endl;
					cin&gt;&gt;_name_;
					_name[i] = _name_;
					cout&lt;&lt;&quot;MHD des Produktes eingeben!\n&quot;&lt;&lt;endl;
					cin&gt;&gt;_mhd_;
					_mhd[i] = _mhd_;

					_mhd.push_back(_mhd_);
				}

	}

}

void ausgabe()
{
	for(int i = 0; i&lt;_name.size(); i++)
				{
					cout&lt;&lt;&quot;Produktname:   &quot;&lt;&lt;_name[i];
					cout&lt;&lt;&quot;\nMHD:           &quot;&lt;&lt;_mhd[i];
					cout&lt;&lt;&quot;. . . . . . . . . . . . . &quot;&lt;&lt;endl;
				}
}

int main ()
{
	start();
	ausgabe();
	getch();
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1980343</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1980343</guid><dc:creator><![CDATA[9A-91]]></dc:creator><pubDate>Sun, 14 Nov 2010 15:39:03 GMT</pubDate></item><item><title><![CDATA[Reply to Vector.Size gibt Vector.Capacity aus on Sun, 14 Nov 2010 15:50:04 GMT]]></title><description><![CDATA[<p>Yeah habs selber rausgefunden <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>
<p>Hab zero auf 0 gesetzt und einfach jeweils pro durchlauf ein push_back eingefügt <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/1980350</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1980350</guid><dc:creator><![CDATA[9A-91]]></dc:creator><pubDate>Sun, 14 Nov 2010 15:50:04 GMT</pubDate></item><item><title><![CDATA[Reply to Vector.Size gibt Vector.Capacity aus on Sun, 14 Nov 2010 16:25:17 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">if(aktion_in == 1 || 2)
</code></pre>
<p>geht in die Hose, du meinst wohl</p>
<pre><code class="language-cpp">if(aktion_in == 1 || aktion_in == 2)
</code></pre>
<p>Wirf &lt;windows.h&gt; raus und benutz keine globalen Variablen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1980367</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1980367</guid><dc:creator><![CDATA[Michael E.]]></dc:creator><pubDate>Sun, 14 Nov 2010 16:25:17 GMT</pubDate></item><item><title><![CDATA[Reply to Vector.Size gibt Vector.Capacity aus on Sun, 14 Nov 2010 16:32:51 GMT]]></title><description><![CDATA[<p>Done.</p>
<p>Wie kann ich Funktionen in Funktionen aufrufen? Weil ich möchte nach jedem durchlauf an den Start zurück! Doch der Start besetht aus zwe Funktions aufrufen. Und so geht das ja nicht...</p>
<p>Ausweichmöglichkeit?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1980369</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1980369</guid><dc:creator><![CDATA[9A-91]]></dc:creator><pubDate>Sun, 14 Nov 2010 16:32:51 GMT</pubDate></item><item><title><![CDATA[Reply to Vector.Size gibt Vector.Capacity aus on Sun, 14 Nov 2010 16:50:54 GMT]]></title><description><![CDATA[<p>9A-91 schrieb:</p>
<blockquote>
<p>Weil ich möchte nach jedem durchlauf an den Start zurück!</p>
</blockquote>
<p>Wie wäre es mit einer Schleife ? <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1980375</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1980375</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 14 Nov 2010 16:50:54 GMT</pubDate></item><item><title><![CDATA[Reply to Vector.Size gibt Vector.Capacity aus on Sun, 14 Nov 2010 16:52:43 GMT]]></title><description><![CDATA[<p>Funktionen kann man in Funktionen aufrufen, in dem man die Funktionen in den Funktionen aufruft <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> ...</p>
<p>In deinem Fall würde ich in der main die beiden Funktionen start() und ausgabe();<br />
in einer Schleife laufen lassen. Vielleicht noch eine zusätzliche Benutzereingabe, ob der das Programm beenden will, oder weitere Produkte eingeben will.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1980377</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1980377</guid><dc:creator><![CDATA[BasicMan01]]></dc:creator><pubDate>Sun, 14 Nov 2010 16:52:43 GMT</pubDate></item></channel></rss>