<?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[Hilfe Namenabfrage funktioniert nicht [Gelöst]]]></title><description><![CDATA[<p>ich möchte ein kleines Spiel machen das ist natürlich nur der Anfang:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;fstream&gt;

using namespace std;

//Funktionsprototypen
char NameAbfrage (char SpielerName[20]);

//Hauptprogramm
int main ()
{
	//Variablen
	char SpielerName[20];	//SpielerName
	char Spielstand;		//Für Abfrage Spielstand

	//Abfrage Spielstand
	cout &lt;&lt; &quot;(n)eues Spiel oder (a)ltes Spiel&quot; &lt;&lt; endl;
	cin &gt;&gt; Spielstand;

	//if else Schachtel
	if (Spielstand == 'n')
	{
		//Menü Ausgabe
		cout &lt;&lt; &quot;Nop-Erstellen&quot; &lt;&lt; endl;
		cout &lt;&lt; &quot;--------------&quot; &lt;&lt; endl;
		NameAbfrage (SpielerName);	//Spielername abfragen
	}//Neuse Spiel

	else if (Spielstand == 'a')
	{

	}//Altes Spiel

	else
	{
		cout &lt;&lt; &quot;Falsche Eingabe&quot; &lt;&lt; endl;
	}

	return 0;
}

// Namen Eingeben für Spiel
//
char NameAbfrage (char SpielerName[20])
{
	cout &lt;&lt; &quot;Bitte Namen fuer Nop eingeben \n(zwischen 1 und 18 Zeichen): &quot;;
	cin.get (SpielerName, 19);
	//Speichern
	ofstream Output (&quot;SpielerName.sp&quot;, ios::binary);
	Output.write ((char*) &amp;SpielerName, sizeof (SpielerName));
	Output.close ();	//Datei schließen

	cout &lt;&lt; endl;

	return 0;
}	//Name
</code></pre>
<p>mein complimierer zeigt keinen Fehler aber wenn ich das Programm starte überspringt er einfach die Namensabfrage. Warum? und wie kann ich das ändern?<br />
Bin erst Anfänger.</p>
<p>/edit pumuckl: [cpp]-Tags eingefügt, nächstemal bitte selber machen <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/topic/247616/hilfe-namenabfrage-funktioniert-nicht-gelöst</link><generator>RSS for Node</generator><lastBuildDate>Thu, 17 Sep 2026 12:25:01 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/247616.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 13 Aug 2009 11:24:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Hilfe Namenabfrage funktioniert nicht [Gelöst] on Thu, 13 Aug 2009 11:54:28 GMT]]></title><description><![CDATA[<p>ich möchte ein kleines Spiel machen das ist natürlich nur der Anfang:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;fstream&gt;

using namespace std;

//Funktionsprototypen
char NameAbfrage (char SpielerName[20]);

//Hauptprogramm
int main ()
{
	//Variablen
	char SpielerName[20];	//SpielerName
	char Spielstand;		//Für Abfrage Spielstand

	//Abfrage Spielstand
	cout &lt;&lt; &quot;(n)eues Spiel oder (a)ltes Spiel&quot; &lt;&lt; endl;
	cin &gt;&gt; Spielstand;

	//if else Schachtel
	if (Spielstand == 'n')
	{
		//Menü Ausgabe
		cout &lt;&lt; &quot;Nop-Erstellen&quot; &lt;&lt; endl;
		cout &lt;&lt; &quot;--------------&quot; &lt;&lt; endl;
		NameAbfrage (SpielerName);	//Spielername abfragen
	}//Neuse Spiel

	else if (Spielstand == 'a')
	{

	}//Altes Spiel

	else
	{
		cout &lt;&lt; &quot;Falsche Eingabe&quot; &lt;&lt; endl;
	}

	return 0;
}

// Namen Eingeben für Spiel
//
char NameAbfrage (char SpielerName[20])
{
	cout &lt;&lt; &quot;Bitte Namen fuer Nop eingeben \n(zwischen 1 und 18 Zeichen): &quot;;
	cin.get (SpielerName, 19);
	//Speichern
	ofstream Output (&quot;SpielerName.sp&quot;, ios::binary);
	Output.write ((char*) &amp;SpielerName, sizeof (SpielerName));
	Output.close ();	//Datei schließen

	cout &lt;&lt; endl;

	return 0;
}	//Name
</code></pre>
<p>mein complimierer zeigt keinen Fehler aber wenn ich das Programm starte überspringt er einfach die Namensabfrage. Warum? und wie kann ich das ändern?<br />
Bin erst Anfänger.</p>
<p>/edit pumuckl: [cpp]-Tags eingefügt, nächstemal bitte selber machen <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/1760017</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1760017</guid><dc:creator><![CDATA[Sarisma]]></dc:creator><pubDate>Thu, 13 Aug 2009 11:54:28 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe Namenabfrage funktioniert nicht [Gelöst] on Thu, 13 Aug 2009 11:28:43 GMT]]></title><description><![CDATA[<p>Liegt wahrscheinlich daran, dass du den Eingabepuffer zwischendurch leeren musst:</p>
<p><a href="http://www.c-plusplus.net/forum/viewtopic-var-p-is-1383244.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-p-is-1383244.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1760022</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1760022</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Thu, 13 Aug 2009 11:28:43 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe Namenabfrage funktioniert nicht [Gelöst] on Thu, 13 Aug 2009 11:39:45 GMT]]></title><description><![CDATA[<p>_matze schrieb:</p>
<blockquote>
<p>Liegt wahrscheinlich daran, dass du den Eingabepuffer zwischendurch leeren musst:</p>
<p><a href="http://www.c-plusplus.net/forum/viewtopic-var-p-is-1383244.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-p-is-1383244.html</a></p>
</blockquote>
<p>also daran liegst nicht habs ausprobiert funktioniert trotzdem nicht.<br />
trotzdem danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1760032</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1760032</guid><dc:creator><![CDATA[Sarisma]]></dc:creator><pubDate>Thu, 13 Aug 2009 11:39:45 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe Namenabfrage funktioniert nicht [Gelöst] on Thu, 13 Aug 2009 11:42:25 GMT]]></title><description><![CDATA[<p>Bau doch einfach nach der Eingabe des Spielerstandes zum Prüfen noch eine Ausgabe ein:</p>
<pre><code class="language-cpp">cout &lt;&lt; &quot;(n)eues Spiel oder (a)ltes Spiel&quot; &lt;&lt; endl;
    cin &gt;&gt; Spielstand;

    cout &lt;&lt; &quot;Eingabe: &quot; &lt;&lt; Spielstand &lt;&lt; endl;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1760036</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1760036</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Thu, 13 Aug 2009 11:42:25 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe Namenabfrage funktioniert nicht [Gelöst] on Thu, 13 Aug 2009 11:45:27 GMT]]></title><description><![CDATA[<p>Doch, liegt daran. Probier das hier mal:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;fstream&gt;

using namespace std;

//Funktionsprototypen
char NameAbfrage (char SpielerName[20]);

//Hauptprogramm
int main ()
{
	//Variablen
	char SpielerName[20];    //SpielerName
	char Spielstand;        //Für Abfrage Spielstand

	//Abfrage Spielstand
	cout &lt;&lt; &quot;(n)eues Spiel oder (a)ltes Spiel&quot; &lt;&lt; endl;
	cin &gt;&gt; Spielstand;

	std::cin.clear();
	std::cin.ignore(std::cin.rdbuf()-&gt;in_avail());

	//if else Schachtel
	if (Spielstand == 'n')
	{
		//Menü Ausgabe
		cout &lt;&lt; &quot;Nop-Erstellen&quot; &lt;&lt; endl;
		cout &lt;&lt; &quot;--------------&quot; &lt;&lt; endl;
		NameAbfrage (SpielerName);    //Spielername abfragen
	}//Neuse Spiel

	else if (Spielstand == 'a')
	{

	}//Altes Spiel

	else
	{
		cout &lt;&lt; &quot;Falsche Eingabe&quot; &lt;&lt; endl;
	}

	getchar();
	return 0;
}

// Namen Eingeben für Spiel
//
char NameAbfrage (char SpielerName[20])
{
	cout &lt;&lt; &quot;Bitte Namen fuer Nop eingeben \n(zwischen 1 und 18 Zeichen): &quot;;
	cin.get (SpielerName, 19);

	std::cin.clear();
	std::cin.ignore(std::cin.rdbuf()-&gt;in_avail());

	//Speichern
	ofstream Output (&quot;SpielerName.sp&quot;, ios::binary);
	Output.write ((char*) &amp;SpielerName, sizeof (SpielerName));
	Output.close ();    //Datei schließen

	cout &lt;&lt; endl;

	return 0;
}    //Name
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1760039</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1760039</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Thu, 13 Aug 2009 11:45:27 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe Namenabfrage funktioniert nicht [Gelöst] on Thu, 13 Aug 2009 11:53:44 GMT]]></title><description><![CDATA[<p>_matze schrieb:</p>
<blockquote>
<p>Doch, liegt daran. Probier das hier mal:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;fstream&gt;

using namespace std;

//Funktionsprototypen
char NameAbfrage (char SpielerName[20]);

//Hauptprogramm
int main ()
{
	//Variablen
	char SpielerName[20];    //SpielerName
	char Spielstand;        //Für Abfrage Spielstand

	//Abfrage Spielstand
	cout &lt;&lt; &quot;(n)eues Spiel oder (a)ltes Spiel&quot; &lt;&lt; endl;
	cin &gt;&gt; Spielstand;
	
	std::cin.clear();
	std::cin.ignore(std::cin.rdbuf()-&gt;in_avail());

	//if else Schachtel
	if (Spielstand == 'n')
	{
		//Menü Ausgabe
		cout &lt;&lt; &quot;Nop-Erstellen&quot; &lt;&lt; endl;
		cout &lt;&lt; &quot;--------------&quot; &lt;&lt; endl;
		NameAbfrage (SpielerName);    //Spielername abfragen
	}//Neuse Spiel

	else if (Spielstand == 'a')
	{

	}//Altes Spiel

	else
	{
		cout &lt;&lt; &quot;Falsche Eingabe&quot; &lt;&lt; endl;
	}

	getchar();
	return 0;
}

// Namen Eingeben für Spiel
//
char NameAbfrage (char SpielerName[20])
{
	cout &lt;&lt; &quot;Bitte Namen fuer Nop eingeben \n(zwischen 1 und 18 Zeichen): &quot;;
	cin.get (SpielerName, 19);

	std::cin.clear();
	std::cin.ignore(std::cin.rdbuf()-&gt;in_avail());

	//Speichern
	ofstream Output (&quot;SpielerName.sp&quot;, ios::binary);
	Output.write ((char*) &amp;SpielerName, sizeof (SpielerName));
	Output.close ();    //Datei schließen

	cout &lt;&lt; endl;

	return 0;
}    //Name
</code></pre>
</blockquote>
<p>vielen dank hattest doch recht jetzt funktioniert.<br />
dann kann ich weiter machen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1760045</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1760045</guid><dc:creator><![CDATA[Sarisma]]></dc:creator><pubDate>Thu, 13 Aug 2009 11:53:44 GMT</pubDate></item></channel></rss>