<?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[Funktionsaufrufe mit Switch]]></title><description><![CDATA[<p>Hey Leute,</p>
<p>ich habe eine Switch-Case Anweisung in der menue.cpp formuliert, die ich über die main aufrufe<br />
In dieser Menü-Auswahl erwarte ich eine Auswahl und lass das ergebnis durch eine switch-anweisung auswerten, die je nach case dann eine funktion laden soll</p>
<p>Soweit so gut, jedoch nach abarbeiten der funktion finde ich mich immer wieder in der menue-auswahl - das soll aber nur geschehen, wenn ich es aus der funktion so auch möchte</p>
<p>Source-Code anbei</p>
<pre><code class="language-cpp">#include &lt;iostream.h&gt;
#include &quot;menue.h&quot;
#include &lt;stdlib.h&gt;

void menue()
{

int iAuswahl;

	do
	{

    system(&quot;cls&quot;);

	cout &lt;&lt; &quot;****************************************************************************\n&quot;;
	cout &lt;&lt; &quot;***               einfache Menuefuehrung mit switch-Auswahl              ***\n&quot;;
	cout &lt;&lt; &quot;****************************************************************************\n&quot;;
	cout &lt;&lt; endl;
	cout &lt;&lt; &quot;[1] - Kontostand abfragen&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;[2] - Geld abheben&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;[3] - Geld einzahlen&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;[4] - Ueberweisung taetigen&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;[5] - Lastschrift einreichen&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;[6] - Dauerauftrag einrichten&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;[7] - Dauerauftrag aendern&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;[8] - Dauerauftrag loeschen&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;[9] - Anweisung abgeben&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;[0] - Programm verlassen&quot; &lt;&lt; endl;
	cout &lt;&lt; endl;
	cout &lt;&lt; endl;
	cout &lt;&lt; &quot;Bitte treffen Sie Ihre Auswahl: &quot; ;

	cin &gt;&gt; iAuswahl;

	switch(iAuswahl)
	{
	case 1:
		{
			kontostand();
			break;
		}
	case 2:
		{
			cout &lt;&lt; &quot;Wieviel moechten Sie abheben? &quot; &lt;&lt; endl;
			cin &gt;&gt; iAuswahl;
			break;
		}
	case 3:
		{
			cout &lt;&lt; &quot;Wieviel moechten Sie einzahlen? &quot; &lt;&lt; endl;
			cin &gt;&gt; iAuswahl;
			break;
		}
	case 4:
		{
			trennlinie();
			break;
		}
	case 5:
	case 6:
	case 7:
	case 8:
	case 9:
		{
			cout &lt;&lt; &quot;Diese Funktion ist nicht belegt!&quot; &lt;&lt; endl;
			break;
		}
	default:
		{
			cout &lt;&lt; &quot;Bitte gueltigen Wert eingeben!&quot; &lt;&lt; endl;
            cin &gt;&gt; iAuswahl;
			break;
		}
	}
	}while(iAuswahl!=0);
}
</code></pre>
<pre><code class="language-cpp">#include &quot;menue.h&quot;
#include &lt;stdlib.h&gt;
#include &lt;iostream.h&gt;

int kontostand()
{
     char cTaste;

     system(&quot;cls&quot;);

     cout &lt;&lt; &quot;*****************************&quot; &lt;&lt; endl;
     cout &lt;&lt; &quot;***      Kontostand       ***&quot; &lt;&lt; endl;
     cout &lt;&lt; &quot;*****************************&quot; &lt;&lt; endl;
     cout &lt;&lt; endl;
     cout &lt;&lt; endl;
     cout &lt;&lt; &quot;Ihr Kontostand betraegt derzeit: _______&quot; &lt;&lt; endl;
     cout &lt;&lt; endl;
     cout &lt;&lt; &quot;Zurueck zum Menue: [j] oder [n]&quot; &lt;&lt; endl;

     cin &gt;&gt; cTaste;

     if (cTaste='j')
     {
     menue();
     }
     else
     return 0;
}
</code></pre>
<p>evtl. könnt ihr mir hierbei helfen (ist nur ein fiktives programm - ich bin wieder-einsteiger und möchte mir einen vokabeltrainer bauen [bewusst mit c++])</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/279216/funktionsaufrufe-mit-switch</link><generator>RSS for Node</generator><lastBuildDate>Mon, 24 Aug 2026 17:26:43 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/279216.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 21 Dec 2010 09:09:21 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Funktionsaufrufe mit Switch on Tue, 21 Dec 2010 09:09:21 GMT]]></title><description><![CDATA[<p>Hey Leute,</p>
<p>ich habe eine Switch-Case Anweisung in der menue.cpp formuliert, die ich über die main aufrufe<br />
In dieser Menü-Auswahl erwarte ich eine Auswahl und lass das ergebnis durch eine switch-anweisung auswerten, die je nach case dann eine funktion laden soll</p>
<p>Soweit so gut, jedoch nach abarbeiten der funktion finde ich mich immer wieder in der menue-auswahl - das soll aber nur geschehen, wenn ich es aus der funktion so auch möchte</p>
<p>Source-Code anbei</p>
<pre><code class="language-cpp">#include &lt;iostream.h&gt;
#include &quot;menue.h&quot;
#include &lt;stdlib.h&gt;

void menue()
{

int iAuswahl;

	do
	{

    system(&quot;cls&quot;);

	cout &lt;&lt; &quot;****************************************************************************\n&quot;;
	cout &lt;&lt; &quot;***               einfache Menuefuehrung mit switch-Auswahl              ***\n&quot;;
	cout &lt;&lt; &quot;****************************************************************************\n&quot;;
	cout &lt;&lt; endl;
	cout &lt;&lt; &quot;[1] - Kontostand abfragen&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;[2] - Geld abheben&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;[3] - Geld einzahlen&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;[4] - Ueberweisung taetigen&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;[5] - Lastschrift einreichen&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;[6] - Dauerauftrag einrichten&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;[7] - Dauerauftrag aendern&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;[8] - Dauerauftrag loeschen&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;[9] - Anweisung abgeben&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;[0] - Programm verlassen&quot; &lt;&lt; endl;
	cout &lt;&lt; endl;
	cout &lt;&lt; endl;
	cout &lt;&lt; &quot;Bitte treffen Sie Ihre Auswahl: &quot; ;

	cin &gt;&gt; iAuswahl;

	switch(iAuswahl)
	{
	case 1:
		{
			kontostand();
			break;
		}
	case 2:
		{
			cout &lt;&lt; &quot;Wieviel moechten Sie abheben? &quot; &lt;&lt; endl;
			cin &gt;&gt; iAuswahl;
			break;
		}
	case 3:
		{
			cout &lt;&lt; &quot;Wieviel moechten Sie einzahlen? &quot; &lt;&lt; endl;
			cin &gt;&gt; iAuswahl;
			break;
		}
	case 4:
		{
			trennlinie();
			break;
		}
	case 5:
	case 6:
	case 7:
	case 8:
	case 9:
		{
			cout &lt;&lt; &quot;Diese Funktion ist nicht belegt!&quot; &lt;&lt; endl;
			break;
		}
	default:
		{
			cout &lt;&lt; &quot;Bitte gueltigen Wert eingeben!&quot; &lt;&lt; endl;
            cin &gt;&gt; iAuswahl;
			break;
		}
	}
	}while(iAuswahl!=0);
}
</code></pre>
<pre><code class="language-cpp">#include &quot;menue.h&quot;
#include &lt;stdlib.h&gt;
#include &lt;iostream.h&gt;

int kontostand()
{
     char cTaste;

     system(&quot;cls&quot;);

     cout &lt;&lt; &quot;*****************************&quot; &lt;&lt; endl;
     cout &lt;&lt; &quot;***      Kontostand       ***&quot; &lt;&lt; endl;
     cout &lt;&lt; &quot;*****************************&quot; &lt;&lt; endl;
     cout &lt;&lt; endl;
     cout &lt;&lt; endl;
     cout &lt;&lt; &quot;Ihr Kontostand betraegt derzeit: _______&quot; &lt;&lt; endl;
     cout &lt;&lt; endl;
     cout &lt;&lt; &quot;Zurueck zum Menue: [j] oder [n]&quot; &lt;&lt; endl;

     cin &gt;&gt; cTaste;

     if (cTaste='j')
     {
     menue();
     }
     else
     return 0;
}
</code></pre>
<p>evtl. könnt ihr mir hierbei helfen (ist nur ein fiktives programm - ich bin wieder-einsteiger und möchte mir einen vokabeltrainer bauen [bewusst mit c++])</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1997497</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1997497</guid><dc:creator><![CDATA[GMoney597]]></dc:creator><pubDate>Tue, 21 Dec 2010 09:09:21 GMT</pubDate></item><item><title><![CDATA[Reply to Funktionsaufrufe mit Switch on Tue, 21 Dec 2010 09:30:11 GMT]]></title><description><![CDATA[<p>Der Aufruf von menue in kontostand ist grundsätzlich falsch. Damit baust du eine Rekursion ein.</p>
<p>Wenn du nicht gleich ins Menü zurückwillst, musst du in kontostand eine Schleife einbauen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1997504</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1997504</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Tue, 21 Dec 2010 09:30:11 GMT</pubDate></item><item><title><![CDATA[Reply to Funktionsaufrufe mit Switch on Tue, 21 Dec 2010 10:20:52 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">switch(iAuswahl)
{
	case 1:
	{
		iAuswahl = kontostand();
		break;
...
}
</code></pre>
<pre><code class="language-cpp">int kontostand()
{
...
	if(cTaste='j')
		return 1;
	else
		return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1997518</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1997518</guid><dc:creator><![CDATA[EOP]]></dc:creator><pubDate>Tue, 21 Dec 2010 10:20:52 GMT</pubDate></item><item><title><![CDATA[Reply to Funktionsaufrufe mit Switch on Tue, 21 Dec 2010 13:17:27 GMT]]></title><description><![CDATA[<p>die neue Anweisung funktioniert soweit ganz gut, aber selbst bei einem 'n' verzweigt er zurück zum menue und verbleibt nicht in der funktion kontostand</p>
<p>edit:<br />
also ich habe es mir folgendermaßen gedacht, dass das programm solange in der funktion kontostand verbleiben soll, bis ich es anweise zurück zum menü zu gehen</p>
<p>was genau funktioniert hat, dass er nicht direkt nach dem aufruf des kontostand wieder in die menüschleife gefallen ist, sondern die funktion kontostand dargestellt wurde<br />
ich denke das lag an</p>
<pre><code class="language-cpp">iAuswahl=kontostand();
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1997526</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1997526</guid><dc:creator><![CDATA[GMoney597]]></dc:creator><pubDate>Tue, 21 Dec 2010 13:17:27 GMT</pubDate></item><item><title><![CDATA[Reply to Funktionsaufrufe mit Switch on Tue, 21 Dec 2010 10:38:56 GMT]]></title><description><![CDATA[<p>GMoney597 schrieb:</p>
<blockquote>
<p>die neue Anweisung funktioniert soweit ganz gut, aber selbst bei einem 'n' verzweigt er zurück zum menue und verbleibt nicht in der funktion kontostand</p>
</blockquote>
<p>Ja, funktioniert ganz gut, außer dass es nicht funktioniert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1997528</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1997528</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Tue, 21 Dec 2010 10:38:56 GMT</pubDate></item><item><title><![CDATA[Reply to Funktionsaufrufe mit Switch on Tue, 21 Dec 2010 11:14:53 GMT]]></title><description><![CDATA[<p>MFK schrieb:</p>
<blockquote>
<p>GMoney597 schrieb:</p>
<blockquote>
<p>die neue Anweisung funktioniert soweit ganz gut, aber selbst bei einem 'n' verzweigt er zurück zum menue und verbleibt nicht in der funktion kontostand</p>
</blockquote>
<p>Ja, funktioniert ganz gut, außer dass es nicht funktioniert.</p>
</blockquote>
<p>&quot;Funktioniert nicht&quot; ist keine ausreichende Fehlerbeschreibung. :p</p>
<p>GMoney597 schrieb:</p>
<blockquote>
<p>die neue Anweisung funktioniert soweit ganz gut, aber selbst bei einem 'n' verzweigt er zurück zum menue und verbleibt nicht in der funktion kontostand</p>
</blockquote>
<p>Wo sollte es denn bleiben am Ende der Funktion kontostand() ? Hat ja keine Schleife.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1997535</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1997535</guid><dc:creator><![CDATA[EOP]]></dc:creator><pubDate>Tue, 21 Dec 2010 11:14:53 GMT</pubDate></item><item><title><![CDATA[Reply to Funktionsaufrufe mit Switch on Tue, 21 Dec 2010 11:13:39 GMT]]></title><description><![CDATA[<p>EOP schrieb:</p>
<blockquote>
<p>&quot;Funktioniert nicht&quot; ist keine ausreichende Fehlerbeschreibung. :p</p>
</blockquote>
<p>Die Fehlerbeschreibung hat GMoney597 doch schon geliefert. Ich hab's nur zusammengefasst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1997537</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1997537</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Tue, 21 Dec 2010 11:13:39 GMT</pubDate></item></channel></rss>