<?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[Char VS String]]></title><description><![CDATA[<p>Hallo und schönen Tag liebe Gemeinde.</p>
<p>Kommenden Mittwoch habe ich im Fach Datenverarbeitungstechnik eine Schulaufgabe. Als Übung darauf habe ich mir ein Programm geschrieben, das ganz klar zwischen Char- und Stringfunktionen(also wirkliche Unterscheidung zwischen dem Datentyp <code>char</code> und <code>string</code> ) &quot;unterscheidet&quot;. Also ich habe einerseits <code>string</code> Funktionen zu <code>string</code> und <code>char</code> Funktionen zu <code>char</code> geschrieben.</p>
<p>Dürfte ich denn diesen ca. 7 bis 8seitigen - zumindest werden bei mir bei Word etwas mehr als 7 Seiten angezeigt - Quellcode hier posten, damit sich den jemand anschauen könnte??</p>
<p>Danke für die Antworten im Voraus. Gruß</p>
<p>Max</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/312976/char-vs-string</link><generator>RSS for Node</generator><lastBuildDate>Sun, 02 Aug 2026 08:41:34 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/312976.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 18 Jan 2013 15:46:56 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Char VS String on Fri, 18 Jan 2013 15:46:56 GMT]]></title><description><![CDATA[<p>Hallo und schönen Tag liebe Gemeinde.</p>
<p>Kommenden Mittwoch habe ich im Fach Datenverarbeitungstechnik eine Schulaufgabe. Als Übung darauf habe ich mir ein Programm geschrieben, das ganz klar zwischen Char- und Stringfunktionen(also wirkliche Unterscheidung zwischen dem Datentyp <code>char</code> und <code>string</code> ) &quot;unterscheidet&quot;. Also ich habe einerseits <code>string</code> Funktionen zu <code>string</code> und <code>char</code> Funktionen zu <code>char</code> geschrieben.</p>
<p>Dürfte ich denn diesen ca. 7 bis 8seitigen - zumindest werden bei mir bei Word etwas mehr als 7 Seiten angezeigt - Quellcode hier posten, damit sich den jemand anschauen könnte??</p>
<p>Danke für die Antworten im Voraus. Gruß</p>
<p>Max</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2291049</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2291049</guid><dc:creator><![CDATA[silent_max]]></dc:creator><pubDate>Fri, 18 Jan 2013 15:46:56 GMT</pubDate></item><item><title><![CDATA[Reply to Char VS String on Fri, 18 Jan 2013 15:51:43 GMT]]></title><description><![CDATA[<p>ich würde vorschlagen, du schmeißt alles in <a href="http://ideone.com" rel="nofollow">ideone.com</a> und gibst uns den Link. Wer Lust hat, sich so viel Code anzuschauen, gibt dir dann Feedback.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2291052</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2291052</guid><dc:creator><![CDATA[*Rewind*]]></dc:creator><pubDate>Fri, 18 Jan 2013 15:51:43 GMT</pubDate></item><item><title><![CDATA[Reply to Char VS String on Fri, 18 Jan 2013 16:09:54 GMT]]></title><description><![CDATA[<p>Muss man sich bei <a href="http://ideone.com" rel="nofollow">ideone.com</a> registrieren??</p>
<p>Edit:</p>
<p>Jetzt hat es geklappt... Hier also der Link:</p>
<p><a href="http://ideone.com/NRYV7U" rel="nofollow">http://ideone.com/NRYV7U</a></p>
<p>Edit²:</p>
<p>Das komische ist, dass bei <a href="http://ideone.com" rel="nofollow">ideone.com</a> ein Fehler gemeldet wird, obwohl es bei meinem Compiler klappt... Strange... :roll:</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2291061</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2291061</guid><dc:creator><![CDATA[silent_max]]></dc:creator><pubDate>Fri, 18 Jan 2013 16:09:54 GMT</pubDate></item><item><title><![CDATA[Reply to Char VS String on Fri, 18 Jan 2013 16:08:44 GMT]]></title><description><![CDATA[<p>Eben nicht ideone. Damit hier alles zusammenbleibt. Wird ja über Jahre archiviert und evtl hilft es ja mal einem viel später nochmal.</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;cstring&gt;
#include &lt;cstdio&gt;
using namespace std;

bool isLonger(string first, string second) 
{
    return first.size() &gt; second.size();
}
string Text(string Eingabe)
{
	cout &lt;&lt; &quot;Geben Sie einen Text ein\n&quot;;
	getline(cin, Eingabe);

	return Eingabe;
}
int main()
{
	int number_1;

	do
	{
		cout &lt;&lt; &quot;Was wollen Sie tun?\n&quot;;
		cout &lt;&lt; &quot;(1) String anschauen\n&quot;;
		cout &lt;&lt; &quot;(2) Char   anschauen\n&quot;;
		cout &lt;&lt; &quot;(0) Exit\n&quot;;
		cin  &gt;&gt; number_1;

		switch(number_1)
		{
		case 1:
			{
				cout &lt;&lt; &quot;Sie haben sich dazu entschieden, einen String anzusehen!\n&quot;;
				cout &lt;&lt; &quot;\n&quot;;
				int number_2;
				do
				{
					cout &lt;&lt; &quot;Was wollen Sie anschauen?\n&quot;;
					cout &lt;&lt; &quot;(01) Passwortabfrage\n&quot;;
					cout &lt;&lt; &quot;(02) Die Laenge zweier Strings miteinander vergleichen\n&quot;;
					cout &lt;&lt; &quot;(03) Stringlaenge anhand von Buchstaben berechnen\n&quot;;
					cout &lt;&lt; &quot;(04) Strings addieren\n&quot;;
					cout &lt;&lt; &quot;(05) String Anfang und Ende ermitteln\n&quot;;
					cout &lt;&lt; &quot;(06) Groesse eines Strings ermitteln\n&quot;;
					cout &lt;&lt; &quot;(07) Refernz auf String\n&quot;;
					cout &lt;&lt; &quot;(08) Operator +=\n&quot;;
					cout &lt;&lt; &quot;(09) 5 Saetze ausgeben\n&quot;;
					cout &lt;&lt; &quot;(00) Zurueck\n&quot;;
					cin  &gt;&gt; number_2;

					switch(number_2)
					{
					case 1:
						{
							string e;
							e = &quot;Maximilian*Maximilian&quot;;

							cout &lt;&lt; &quot;\n&quot;;
							cout &lt;&lt; &quot;\t Menuepunkt(01) Passwortabfrage!\n&quot;;
							cout &lt;&lt; &quot;\n&quot;;

							do
							{ 
								cout &lt;&lt; &quot;Wie lautet das Passwort?\n&quot;;
								cin  &gt;&gt; e;
								if(e==&quot;Maximilian*Maximilian&quot;)
									cout &lt;&lt; &quot;Richtig eingegeben&quot;;
								else
									cout &lt;&lt; &quot;Nicht richtig eingegeben!\n&quot;;
							}while(e!=&quot;Maximilian*Maximilian&quot;);

							break;
						}
					case 2:
						{
							cout &lt;&lt; &quot;\tMenuepunkt(02) Die Laenge zweier Strings miteinander vergleichen\n&quot;;
							string erste;
							cin &gt;&gt; erste;
							string zweite;
							cin &gt;&gt; zweite;
							if(isLonger(erste,zweite))
								cout &lt;&lt; &quot;Der erste ist lÃ¤nger&quot;;
							else
							cout &lt;&lt; &quot;Der zweite ist lÃ¤nger&quot;;
							break;
						}
					case 3:
						{
							cout &lt;&lt; &quot;\tMenuepunkt(03) Stringlaenge anhand von Buchstaben berechnen\n&quot;;
							string str;

							cout &lt;&lt; &quot;Bitte geben Sie einen Text ein!\n&quot;;
							getline(cin, str);

							cout &lt;&lt; &quot;Ihr Text hat &quot; &lt;&lt; str.size() &lt;&lt; &quot; Buchstaben\n&quot;;
							break;
						}
					case 4:
						{
							cout &lt;&lt; &quot;\tMenuepunkt(04) Strings addieren\n&quot;;
							string Text_1, Text_2, Text_3;

							cout &lt;&lt; &quot;Geben Sie die erste Haelfte des Satzes ein:\n&quot;;
							getline(cin, Text_1);

							cout &lt;&lt; &quot;Geben Sie die zweite Haelfte des Satzes ein:\n&quot;;
							getline(cin, Text_2);

							Text_3 = Text_1 + Text_2;

							cout &lt;&lt; &quot;Zusammengefuegt heisst der Satz:\n&quot;;
							cout &lt;&lt; Text_3;
							break;
						}
					case 5:
						{
							cout &lt;&lt; &quot;\tMenuepunkt(05) String Anfang und Ende ermitteln\n&quot;;

							string str(&quot;Test string&quot;);
							string::iterator it;

							for (it=str.begin(); it &lt; str.end(); it++)
							cout &lt;&lt; *it;

							break;
						}
					case 6:
						{
							cout &lt;&lt; &quot;\tMenuepunkt(06) Groesse eines Strings ermitteln\n&quot;;

							string Text;
							cout &lt;&lt; &quot;Geben Sie einen Text ein!\n&quot;;
							cin  &gt;&gt; Text;

							cout &lt;&lt; sizeof(Text) &lt;&lt; &quot;\n&quot;;
							cout &lt;&lt; &quot;Groesse:\t &quot; &lt;&lt; Text.size() &lt;&lt; &quot;\n&quot;;
							cout &lt;&lt; &quot;Laenge:\t&quot; &lt;&lt; Text.length ()&lt;&lt; &quot;\n&quot;;
							cout &lt;&lt; &quot;Kapazitaet:\t&quot; &lt;&lt; Text.capacity() &lt;&lt; &quot;\n&quot;;
							cout &lt;&lt; &quot;Max. Laenge:\t&quot; &lt;&lt; Text.max_size() &lt;&lt; &quot;\n&quot;;

							break;
						}
					case 7:
						{
							cout &lt;&lt; &quot;Menuepunkt(07) Refernz auf String\n&quot;;

							string Eingabe;
							string &amp;Text_1 =Text(Eingabe);
							cout &lt;&lt; Text_1 &lt;&lt; &quot;\n&quot;;

							break;
						}
					case 8:
						{
							cout &lt;&lt; &quot;Menuepunkt(08) Operator +=\n&quot;; 

							string Vorname;
							string Familienname;

							cout &lt;&lt; &quot;Geben Sie Ihren Vornamen ein: \n&quot;;
							getline(cin, Vorname);

							cout &lt;&lt; &quot;Geben Sie Ihren Familiennamen ein: \n&quot;;
							getline(cin, Familienname);

							Vorname += Familienname;
							Vorname += '\n';

							cout &lt;&lt; Vorname &lt;&lt; &quot;\n&quot;;

							break;
						}
					case 9:
						{
							cout &lt;&lt; &quot;Menuepunkt(09) 5 Saetze ausgeben\n&quot;;
							string Satz[5];

							cout &lt;&lt; &quot;Geben Sie fuenf Saetze ein!\n&quot;;

							for (int i=0; i&lt;5; i++)
							{
								cout &lt;&lt; &quot;Satz[&quot; &lt;&lt; i &lt;&lt;&quot;]: &quot;;
								getline(cin, Satz[i]);
							}

							cout &lt;&lt; &quot;\n&quot;;
							cout &lt;&lt; &quot;Das haben Sie eingegeben: \n&quot;;
							cout &lt;&lt; &quot;\n&quot;;

							for (int i=0; i&lt;5; i++)
							{
								cout &lt;&lt; &quot;Satz[&quot; &lt;&lt; i &lt;&lt; &quot;]: &quot; &lt;&lt; Satz[i] &lt;&lt; &quot;\n&quot;;
							}

							cout &lt;&lt; &quot;\n&quot;;
							break;
						}
					case 0:
						{
							cout &lt;&lt; &quot;Menuepunkt Zurueck\n&quot;;
							break;
						}
					}
				}while(number_2!=0);
				break;
			}
		case 2:
			{
				cout &lt;&lt; &quot;Sie haben sich dazu entschieden, einen Char anzusehen!\n&quot;;
				cout &lt;&lt; &quot;\n&quot;;
				int number_3;
				do
				{
					cout &lt;&lt; &quot;Was wollen Sie anschauen?\n&quot;;
					cout &lt;&lt; &quot;(01) Funktion strrchr\n&quot;;
					cout &lt;&lt; &quot;(02) Funktion strchr\n&quot;;
					cout &lt;&lt; &quot;(03) Suche nach einem Buchstaben in einem Satz\n&quot;;
					cout &lt;&lt; &quot;(04) Funktion getline\n&quot;;
					cout &lt;&lt; &quot;(05) Funktion putback\n&quot;;
					cout &lt;&lt; &quot;(06) Funktion put(char)\n&quot;;
					cout &lt;&lt; &quot;(07) Funktion strstr() bzw. die Suche nach Woertern in einem Text\n&quot;;
					cout &lt;&lt; &quot;(00) Zurueck\n&quot;;
					cin  &gt;&gt; number_3;

					switch(number_3)
					{
					case 1: 
						{
							cout &lt;&lt; &quot;Menuepunkt (01) Funktion strrchr\n&quot;;
							char str []= &quot;Das ist ein einfacher string.\n&quot;;
							char * pstr;

							cout &lt;&lt; str;

							pstr = strrchr(str,'s');

							cout &lt;&lt; &quot;Letzte Stelle von 's' wurde gefunden an &quot; &lt;&lt; pstr-str+1 &lt;&lt; &quot; \n&quot;;
							break;
						}
					case 2:
						{
							cout &lt;&lt; &quot;Menuepunkt (02) Funktion strchr\n&quot;;

							char str[]=&quot;Das ist ein einfacher string&quot;;
							char *pch;

							cout &lt;&lt; &quot;Gesucht wird das 's' in &quot; &lt;&lt; str &lt;&lt; &quot;\n&quot;;

							pch = strchr(str,'s');

							while(pch!=NULL)
							{
								cout &lt;&lt; &quot;Gefunden an &quot; &lt;&lt; pch-str+1 &lt;&lt; &quot;\n&quot;;
								pch = strchr(pch+1,'s');
							}

							break;
						}

					case 3:
						{
							cout &lt;&lt; &quot;Menuepunkt(03) Suche nach einem Buchstaben in einem Satz\n&quot;;

							char String[10000];
							char *pString;
							char Buchstabe;

							cout &lt;&lt; &quot;Geben Sie einen String von weniger als 10000 Buchstaben ein!\n&quot;;
							gets(String);

							cout &lt;&lt; &quot;Nach welchem Buchstaben soll gesucht werden?\n &quot;;
							cin  &gt;&gt; Buchstabe;

							pString = strchr(String, Buchstabe);

							while(pString!=NULL)
							{
								cout &lt;&lt; &quot;Gefunden an &quot; &lt;&lt; pString-String+1 &lt;&lt; &quot;\n&quot;;
								pString = strchr(pString+1, Buchstabe);
							}
							break;
						}
					case 4:
						{
							cout &lt;&lt; &quot;Menuepunkt(04) Funktion getline\n&quot;;
							char name[256], titel[256];

							cout &lt;&lt; &quot;Geben Sie Ihren Namen ein:&quot;;
							cin.getline(name,256);

							cout &lt;&lt; &quot;Geben Sie Ihren Lieblingsfilm ein:&quot;;
							cin.getline(titel,256);

							cout &lt;&lt; name &lt;&lt; &quot;Â´s Lieblingsfilm ist &quot; &lt;&lt; titel &lt;&lt; &quot;\n&quot;;
							break;
						}
					case 5:
						{
							cout &lt;&lt; &quot;Menuepunkt (05) Funktion putback\n&quot;; 
							char c;
							int n;
							char str[256];

							cout &lt;&lt; &quot;Geben Sie eine Zahl oder ein Wort ein:&quot;;
							c = cin.get();

							if((c&gt;='0')&amp;&amp;(c&lt;='9'))
							{
								cin.putback(c);
								cin  &gt;&gt; n;
								cout &lt;&lt; &quot;Sie haben eine Nummer eingegeben &quot; &lt;&lt; n &lt;&lt; endl;
							}
							else
							{
								cin.putback(c);
								cin  &gt;&gt; str;
								cout &lt;&lt; &quot;Sie haben ein Wort eingegeben &quot; &lt;&lt; str &lt;&lt; endl;
							}

							break;
						}
					case 6:
						{
							cout &lt;&lt; &quot;Menuepunkt (06) Funktion put(char)\n&quot;;

							char c;

							cout &lt;&lt; &quot;Geben Sie einen Buchstaben ein!\n&quot;;
							cin  &gt;&gt; c;

							for(c = c; c&lt;='z'; c++)
							{
								putchar(c);
							}

							break;
						}
					case 7:
						{
							cout &lt;&lt; &quot;Menuepunkt (07) Funktion strstr() bzw. die Suche nach Woertern in einem Text\n&quot;;
							char String[100000];
							char *pString;
							char Wort[256];

							cout &lt;&lt; &quot;Geben Sie einen Text von weniger als 100000 Buchstaben ein!\n&quot;;
							gets(String);

							cout &lt;&lt; &quot;Nach welchem Wort soll gesucht werden?\n&quot;;
							cin.getline(Wort, 256);

							pString = strstr(String, Wort);

							while(pString!=NULL)
							{
								cout &lt;&lt; &quot;Gefunden an &quot; &lt;&lt; pString-String+1 &lt;&lt; &quot;\n&quot;;
								pString = strstr(pString+1, Wort);
							}
							break;
						}
					case 0:
						{
							cout &lt;&lt; &quot;Zurueck!\n&quot;;
							break;
						}
					}

				}while(number_3!=0);
				break;
			}
		case 3:
			{
				cout &lt;&lt; &quot;Exit durch Abbruch!\n&quot;;
				break;
			}

		}
	}while(number_1!=0);

	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2291066</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2291066</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Fri, 18 Jan 2013 16:08:44 GMT</pubDate></item><item><title><![CDATA[Reply to Char VS String on Fri, 18 Jan 2013 16:13:16 GMT]]></title><description><![CDATA[<p>silent_max schrieb:</p>
<blockquote>
<p>(also wirkliche Unterscheidung zwischen dem Datentyp <code>char</code> und <code>string</code> )</p>
</blockquote>
<p>Die Unterscheidung ist einfach: ein char speichert ein einzelnes Zeichen, ein String speichert viele Zeichen.</p>
<p>Das kommt dir vielleicht wie Klugscheißerei vor, aber sich präzise auszudrücken ist beim Programmieren wichtig. Wenn du also ein char-array meinst, dann nenn es auch so.</p>
<p>Ich würde an deiner Stelle dein Programm in einzelne Funktionen gliedern. Das sieht sauberer aus und ist weniger Arbeit, weil du dich weniger oft wiederholen musst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2291070</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2291070</guid><dc:creator><![CDATA[Captain Obvious]]></dc:creator><pubDate>Fri, 18 Jan 2013 16:13:16 GMT</pubDate></item><item><title><![CDATA[Reply to Char VS String on Fri, 18 Jan 2013 16:11:59 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>Eben nicht ideone. Damit hier alles zusammenbleibt. Wird ja über Jahre archiviert und evtl hilft es ja mal einem viel später nochmal.</p>
</blockquote>
<p>Oder so <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/2291071</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2291071</guid><dc:creator><![CDATA[silent_max]]></dc:creator><pubDate>Fri, 18 Jan 2013 16:11:59 GMT</pubDate></item><item><title><![CDATA[Reply to Char VS String on Fri, 18 Jan 2013 16:30:52 GMT]]></title><description><![CDATA[<p>Captain Obvious schrieb:</p>
<blockquote>
<p>Das kommt dir vielleicht wie Klugscheißerei vor, aber sich präzise auszudrücken ist beim Programmieren wichtig. Wenn du also ein char-array meinst, dann nenn es auch so.</p>
</blockquote>
<p>Ich meinte den <code>char</code> String...</p>
<p>Edit:</p>
<p>Ich muss ein paar Veränderungen vornehmen. Bei manchen Menüpunkten funktioniert die Texteingabe nicht... muss ich wohl mit <code>cin::ignore()</code> ändern??</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2291080</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2291080</guid><dc:creator><![CDATA[silent_max]]></dc:creator><pubDate>Fri, 18 Jan 2013 16:30:52 GMT</pubDate></item><item><title><![CDATA[Reply to Char VS String on Fri, 18 Jan 2013 16:38:38 GMT]]></title><description><![CDATA[<p>char-array oder C-String. Nicht char, nicht char String. Keine Wörter erfinden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2291088</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2291088</guid><dc:creator><![CDATA[Captain Obvious]]></dc:creator><pubDate>Fri, 18 Jan 2013 16:38:38 GMT</pubDate></item><item><title><![CDATA[Reply to Char VS String on Fri, 18 Jan 2013 16:43:52 GMT]]></title><description><![CDATA[<p>Captain Obvious schrieb:</p>
<blockquote>
<p>char-array oder C-String. Nicht char, nicht char String. Keine Wörter erfinden.</p>
</blockquote>
<p>Entschuldigung...</p>
<p>Ich wollte Funktionen zwischen <code>C-String</code> und <code>C++-String</code> unterscheiden...</p>
<p>So jetzt funktioniert es:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;cstring&gt;
#include &lt;cstdio&gt;
using namespace std;

bool isLonger(string first, string second) 
{
	return first.size() &gt; second.size();
}
string Text(string Eingabe)
{
	cout &lt;&lt; &quot;Geben Sie einen Text ein\n&quot;;
	getline(cin, Eingabe);

	return Eingabe;
}
int main()
{
	int number_1;

	do
	{
		cout &lt;&lt; &quot;Was wollen Sie tun?\n&quot;;
		cout &lt;&lt; &quot;(1) String anschauen\n&quot;;
		cout &lt;&lt; &quot;(2) Char   anschauen\n&quot;;
		cout &lt;&lt; &quot;(0) Exit\n&quot;;
		cin  &gt;&gt; number_1;

		switch(number_1)
		{
		case 1:
			{
				cout &lt;&lt; &quot;Sie haben sich dazu entschieden, einen String anzusehen!\n&quot;;
				cout &lt;&lt; &quot;\n&quot;;
				int number_2;
				do
				{
					cout &lt;&lt; &quot;Was wollen Sie anschauen?\n&quot;;
					cout &lt;&lt; &quot;(01) Passwortabfrage\n&quot;;
					cout &lt;&lt; &quot;(02) Die Laenge zweier Strings miteinander vergleichen\n&quot;;
					cout &lt;&lt; &quot;(03) Stringlaenge anhand von Buchstaben berechnen\n&quot;;
					cout &lt;&lt; &quot;(04) Strings addieren\n&quot;;
					cout &lt;&lt; &quot;(05) String Anfang und Ende ermitteln\n&quot;;
					cout &lt;&lt; &quot;(06) Groesse eines Strings ermitteln\n&quot;;
					cout &lt;&lt; &quot;(07) Refernz auf String\n&quot;;
					cout &lt;&lt; &quot;(08) Operator +=\n&quot;;
					cout &lt;&lt; &quot;(09) 5 Saetze ausgeben\n&quot;;
					cout &lt;&lt; &quot;(00) Zurueck\n&quot;;
					cin  &gt;&gt; number_2;

					switch(number_2)
					{
					case 1:
						{
							string e;
							e = &quot;Maximilian*Maximilian&quot;;

							cout &lt;&lt; &quot;\n&quot;;
							cout &lt;&lt; &quot;\t Menuepunkt(01) Passwortabfrage!\n&quot;;
							cout &lt;&lt; &quot;\n&quot;;

							do
							{ 
								cout &lt;&lt; &quot;Wie lautet das Passwort?\n&quot;;
								cin  &gt;&gt; e;
								if(e==&quot;Maximilian*Maximilian&quot;)
									cout &lt;&lt; &quot;Richtig eingegeben&quot;;
								else
									cout &lt;&lt; &quot;Nicht richtig eingegeben!\n&quot;;
							}while(e!=&quot;Maximilian*Maximilian&quot;);

							break;
						}
					case 2:
						{
							cout &lt;&lt; &quot;\tMenuepunkt(02) Die Laenge zweier Strings miteinander vergleichen\n&quot;;
							string erste;
							cin &gt;&gt; erste;
							string zweite;
							cin &gt;&gt; zweite;
							if(isLonger(erste,zweite))
								cout &lt;&lt; &quot;Der erste ist länger&quot;;
							else
							cout &lt;&lt; &quot;Der zweite ist länger&quot;;
							break;
						}
					case 3:
						{
							cin.ignore(2);
							cout &lt;&lt; &quot;\tMenuepunkt(03) Stringlaenge anhand von Buchstaben berechnen\n&quot;;
							string str;

							cout &lt;&lt; &quot;Bitte geben Sie einen Text ein!\n&quot;;
							getline(cin, str);

							cout &lt;&lt; &quot;Ihr Text hat &quot; &lt;&lt; str.size() &lt;&lt; &quot; Buchstaben\n&quot;;
							break;
						}
					case 4:
						{
							cin.ignore(3);
							cout &lt;&lt; &quot;\tMenuepunkt(04) Strings addieren\n&quot;;
							string Text_1, Text_2, Text_3;

							cout &lt;&lt; &quot;Geben Sie die erste Haelfte des Satzes ein:\n&quot;;
							getline(cin, Text_1);

							cout &lt;&lt; &quot;Geben Sie die zweite Haelfte des Satzes ein:\n&quot;;
							getline(cin, Text_2);

							Text_3 = Text_1 + Text_2;

							cout &lt;&lt; &quot;Zusammengefuegt heisst der Satz:\n&quot;;
							cout &lt;&lt; Text_3;
							break;
						}
					case 5:
						{
							cin.ignore(4);
							cout &lt;&lt; &quot;\tMenuepunkt(05) String Anfang und Ende ermitteln\n&quot;;

							string str(&quot;Test string&quot;);
							string::iterator it;

							for (it=str.begin(); it &lt; str.end(); it++)
							cout &lt;&lt; *it;

							break;
						}
					case 6:
						{
							cin.ignore(5);
							cout &lt;&lt; &quot;\tMenuepunkt(06) Groesse eines Strings ermitteln\n&quot;;

							string Text;
							cout &lt;&lt; &quot;Geben Sie einen Text ein!\n&quot;;
							cin  &gt;&gt; Text;

							cout &lt;&lt; sizeof(Text) &lt;&lt; &quot;\n&quot;;
							cout &lt;&lt; &quot;Groesse:\t &quot; &lt;&lt; Text.size() &lt;&lt; &quot;\n&quot;;
							cout &lt;&lt; &quot;Laenge:\t&quot; &lt;&lt; Text.length ()&lt;&lt; &quot;\n&quot;;
							cout &lt;&lt; &quot;Kapazitaet:\t&quot; &lt;&lt; Text.capacity() &lt;&lt; &quot;\n&quot;;
							cout &lt;&lt; &quot;Max. Laenge:\t&quot; &lt;&lt; Text.max_size() &lt;&lt; &quot;\n&quot;;

							break;
						}
					case 7:
						{
							cin.ignore(6);
							cout &lt;&lt; &quot;Menuepunkt(07) Refernz auf String\n&quot;;

							string Eingabe;
							string &amp;Text_1 =Text(Eingabe);
							cout &lt;&lt; Text_1 &lt;&lt; &quot;\n&quot;;

							break;
						}
					case 8:
						{
							cin.ignore(7);
							cout &lt;&lt; &quot;Menuepunkt(08) Operator +=\n&quot;; 

							string Vorname;
							string Familienname;

							cout &lt;&lt; &quot;Geben Sie Ihren Vornamen ein: \n&quot;;
							getline(cin, Vorname);

							cout &lt;&lt; &quot;Geben Sie Ihren Familiennamen ein: \n&quot;;
							getline(cin, Familienname);

							Vorname += Familienname;
							Vorname += '\n';

							cout &lt;&lt; Vorname &lt;&lt; &quot;\n&quot;;

							break;
						}
					case 9:
						{
							cin.ignore(8);
							cout &lt;&lt; &quot;Menuepunkt(09) 5 Saetze ausgeben\n&quot;;
							string Satz[5];

							cout &lt;&lt; &quot;Geben Sie fuenf Saetze ein!\n&quot;;

							for (int i=0; i&lt;5; i++)
							{
								cout &lt;&lt; &quot;Satz[&quot; &lt;&lt; i &lt;&lt;&quot;]: &quot;;
								getline(cin, Satz[i]);
							}

							cout &lt;&lt; &quot;\n&quot;;
							cout &lt;&lt; &quot;Das haben Sie eingegeben: \n&quot;;
							cout &lt;&lt; &quot;\n&quot;;

							for (int i=0; i&lt;5; i++)
							{
								cout &lt;&lt; &quot;Satz[&quot; &lt;&lt; i &lt;&lt; &quot;]: &quot; &lt;&lt; Satz[i] &lt;&lt; &quot;\n&quot;;
							}

							cout &lt;&lt; &quot;\n&quot;;
							break;
						}
					case 0:
						{
							cout &lt;&lt; &quot;Menuepunkt Zurueck\n&quot;;
							break;
						}
					}
				}while(number_2!=0);
				break;
			}
		case 2:
			{
				cout &lt;&lt; &quot;Sie haben sich dazu entschieden, einen Char anzusehen!\n&quot;;
				cout &lt;&lt; &quot;\n&quot;;
				int number_3;
				do
				{
					cout &lt;&lt; &quot;Was wollen Sie anschauen?\n&quot;;
					cout &lt;&lt; &quot;(01) Funktion strrchr\n&quot;;
					cout &lt;&lt; &quot;(02) Funktion strchr\n&quot;;
					cout &lt;&lt; &quot;(03) Suche nach einem Buchstaben in einem Satz\n&quot;;
					cout &lt;&lt; &quot;(04) Funktion getline\n&quot;;
					cout &lt;&lt; &quot;(05) Funktion putback\n&quot;;
					cout &lt;&lt; &quot;(06) Funktion put(char)\n&quot;;
					cout &lt;&lt; &quot;(07) Funktion strstr() bzw. die Suche nach Woertern in einem Text\n&quot;;
					cout &lt;&lt; &quot;(00) Zurueck\n&quot;;
					cin  &gt;&gt; number_3;

					switch(number_3)
					{
					case 1: 
						{
							cout &lt;&lt; &quot;Menuepunkt (01) Funktion strrchr\n&quot;;
							char str []= &quot;Das ist ein einfacher string.\n&quot;;
							char * pstr;

							cout &lt;&lt; str;

							pstr = strrchr(str,'s');

							cout &lt;&lt; &quot;Letzte Stelle von 's' wurde gefunden an &quot; &lt;&lt; pstr-str+1 &lt;&lt; &quot; \n&quot;;
							break;
						}
					case 2:
						{
							cin.ignore(2);
							cout &lt;&lt; &quot;Menuepunkt (02) Funktion strchr\n&quot;;

							char str[]=&quot;Das ist ein einfacher string&quot;;
							char *pch;

							cout &lt;&lt; &quot;Gesucht wird das 's' in &quot; &lt;&lt; str &lt;&lt; &quot;\n&quot;;

							pch = strchr(str,'s');

							while(pch!=NULL)
							{
								cout &lt;&lt; &quot;Gefunden an &quot; &lt;&lt; pch-str+1 &lt;&lt; &quot;\n&quot;;
								pch = strchr(pch+1,'s');
							}

							break;
						}

					case 3:
						{
							cout &lt;&lt; &quot;Menuepunkt(03) Suche nach einem Buchstaben in einem Satz\n&quot;;

							char String[10000];
							char *pString;
							char Buchstabe;

							cout &lt;&lt; &quot;Geben Sie einen String von weniger als 10000 Buchstaben ein!\n&quot;;
							gets(String);

							cout &lt;&lt; &quot;Nach welchem Buchstaben soll gesucht werden?\n &quot;;
							cin  &gt;&gt; Buchstabe;

							pString = strchr(String, Buchstabe);

							while(pString!=NULL)
							{
								cout &lt;&lt; &quot;Gefunden an &quot; &lt;&lt; pString-String+1 &lt;&lt; &quot;\n&quot;;
								pString = strchr(pString+1, Buchstabe);
							}
							break;
						}
					case 4:
						{
							cin.ignore(3);
							cout &lt;&lt; &quot;Menuepunkt(04) Funktion getline\n&quot;;
							char name[256], titel[256];

							cout &lt;&lt; &quot;Geben Sie Ihren Namen ein:&quot;;
							cin.getline(name,256);

							cout &lt;&lt; &quot;Geben Sie Ihren Lieblingsfilm ein:&quot;;
							cin.getline(titel,256);

							cout &lt;&lt; name &lt;&lt; &quot;´s Lieblingsfilm ist &quot; &lt;&lt; titel &lt;&lt; &quot;\n&quot;;
							break;
						}
					case 5:
						{
							cin.ignore(4);
							cout &lt;&lt; &quot;Menuepunkt (05) Funktion putback\n&quot;; 
							char c;
							int n;
							char str[256];

							cout &lt;&lt; &quot;Geben Sie eine Zahl oder ein Wort ein:&quot;;
							c = cin.get();

							if((c&gt;='0')&amp;&amp;(c&lt;='9'))
							{
								cin.putback(c);
								cin  &gt;&gt; n;
								cout &lt;&lt; &quot;Sie haben eine Nummer eingegeben &quot; &lt;&lt; n &lt;&lt; endl;
							}
							else
							{
								cin.putback(c);
								cin  &gt;&gt; str;
								cout &lt;&lt; &quot;Sie haben ein Wort eingegeben &quot; &lt;&lt; str &lt;&lt; endl;
							}

							break;
						}
					case 6:
						{
							cin.ignore(5);
							cout &lt;&lt; &quot;Menuepunkt (06) Funktion put(char)\n&quot;;

							char c;

							cout &lt;&lt; &quot;Geben Sie einen Buchstaben ein!\n&quot;;
							cin  &gt;&gt; c;

							for(c = c; c&lt;='z'; c++)
							{
								putchar(c);
							}

							break;
						}
					case 7:
						{
							cin.ignore(6);
							cout &lt;&lt; &quot;Menuepunkt (07) Funktion strstr() bzw. die Suche nach Woertern in einem Text\n&quot;;
							char String[100000];
							char *pString;
							char Wort[256];

							cout &lt;&lt; &quot;Geben Sie einen Text von weniger als 100000 Buchstaben ein!\n&quot;;
							gets(String);

							cout &lt;&lt; &quot;Nach welchem Wort soll gesucht werden?\n&quot;;
							cin.getline(Wort, 256);

							pString = strstr(String, Wort);

							while(pString!=NULL)
							{
								cout &lt;&lt; &quot;Gefunden an &quot; &lt;&lt; pString-String+1 &lt;&lt; &quot;\n&quot;;
								pString = strstr(pString+1, Wort);
							}
							break;
						}
					case 0:
						{
							cout &lt;&lt; &quot;Zurueck!\n&quot;;
							break;
						}
					}

				}while(number_3!=0);
				break;
			}
		case 3:
			{
				cout &lt;&lt; &quot;Exit durch Abbruch!\n&quot;;
				break;
			}

		}
	}while(number_1!=0);

	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2291091</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2291091</guid><dc:creator><![CDATA[silent_max]]></dc:creator><pubDate>Fri, 18 Jan 2013 16:43:52 GMT</pubDate></item><item><title><![CDATA[Reply to Char VS String on Fri, 18 Jan 2013 16:57:18 GMT]]></title><description><![CDATA[<p>Irgendwann ist dir das bestimmt schon mal geschrieben worden:</p>
<pre><code>gets(String);
</code></pre>
<p>Das solltest du nicht mehr in aktuellem Code nutzen.<br />
Zum Einen ist es unsicher.<br />
Zum 2. ist es in den Standardkomitees auf der Streichliste. D.h. es kann sein das es im nächsten Standard gar nicht mehr zulässig ist.</p>
<p>Auch Microsoft schreibt in der MSDN gets() nicht mehr nutzen.</p>
<p>Aber dies ist wahrscheinlich vergebens geschrieben. Du ignorierst das ja eh, oder diesmal nicht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2291097</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2291097</guid><dc:creator><![CDATA[f.-th.]]></dc:creator><pubDate>Fri, 18 Jan 2013 16:57:18 GMT</pubDate></item><item><title><![CDATA[Reply to Char VS String on Fri, 18 Jan 2013 17:15:46 GMT]]></title><description><![CDATA[<p>Mach doch erstma, dass Ideone deine Programm auch kompiliert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2291105</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2291105</guid><dc:creator><![CDATA[ScottZhang]]></dc:creator><pubDate>Fri, 18 Jan 2013 17:15:46 GMT</pubDate></item><item><title><![CDATA[Reply to Char VS String on Fri, 18 Jan 2013 18:26:23 GMT]]></title><description><![CDATA[<p>silent_max schrieb:</p>
<blockquote>
<pre><code>string Text(string Eingabe)
{
	cout &lt;&lt; &quot;Geben Sie einen Text ein\n&quot;;
	getline(cin, Eingabe);

	return Eingabe;
}
</code></pre>
</blockquote>
<p>Warum ist &quot;Eingabe&quot; ein Funktions-Parameter?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2291132</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2291132</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Fri, 18 Jan 2013 18:26:23 GMT</pubDate></item><item><title><![CDATA[Reply to Char VS String on Fri, 18 Jan 2013 21:32:51 GMT]]></title><description><![CDATA[<p>silent_max schrieb:</p>
<blockquote>
<pre><code class="language-cpp">case 7:
    {
        cin.ignore(6);
	cout &lt;&lt; &quot;Menuepunkt(07) Refernz auf String\n&quot;;
							
	string Eingabe;                 // nicht initialisiert
	string &amp;Text_1 =Text(Eingabe);  // und hier sinnlos übergeben
	cout &lt;&lt; Text_1 &lt;&lt; &quot;\n&quot;;
					
	break;
    }
</code></pre>
</blockquote>
<p>und da meckert dein Compiler nicht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2291183</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2291183</guid><dc:creator><![CDATA[fan von silent_max]]></dc:creator><pubDate>Fri, 18 Jan 2013 21:32:51 GMT</pubDate></item><item><title><![CDATA[Reply to Char VS String on Fri, 18 Jan 2013 21:40:52 GMT]]></title><description><![CDATA[<p>Hallo silent_max,<br />
was sollen die ganzen <strong>cin.ignore()</strong>?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2291187</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2291187</guid><dc:creator><![CDATA[klaus2013]]></dc:creator><pubDate>Fri, 18 Jan 2013 21:40:52 GMT</pubDate></item><item><title><![CDATA[Reply to Char VS String on Sat, 19 Jan 2013 09:10:50 GMT]]></title><description><![CDATA[<p>klaus2013 schrieb:</p>
<blockquote>
<p>Hallo silent_max,<br />
was sollen die ganzen <strong>cin.ignore()</strong>?</p>
</blockquote>
<p>Ohne diese <code>cin.ignore()</code> überspringt mein Compiler mancherlei Texteingaben...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2291242</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2291242</guid><dc:creator><![CDATA[silent_max]]></dc:creator><pubDate>Sat, 19 Jan 2013 09:10:50 GMT</pubDate></item><item><title><![CDATA[Reply to Char VS String on Sat, 19 Jan 2013 09:37:36 GMT]]></title><description><![CDATA[<p>f.-th. schrieb:</p>
<blockquote>
<p>Aber dies ist wahrscheinlich vergebens geschrieben. Du ignorierst das ja eh, oder diesmal nicht?</p>
</blockquote>
<p>Es ist schon ein paar Mal geschrieben worden. Andererseits weiß ich jedoch nicht, wie ich einen C-String, also <code>char</code> , per Tastatur einlesen soll.</p>
<p>Mit <code>cin.getline</code> ??</p>
<p>Edit:</p>
<p>Wenn ich in Zeile 270 statt</p>
<pre><code class="language-cpp">gets(String)
</code></pre>
<p>den Code</p>
<pre><code class="language-cpp">cin.getline(String)
</code></pre>
<p>schreibe, dann bekomme ich folgende Fehlermeldung:</p>
<pre><code class="language-cpp">error C2661: 'std::basic_istream&lt;_Elem,_Traits&gt;::getline': Keine überladene Funktion akzeptiert 1 Argumente
</code></pre>
<p>Edit²:</p>
<p>Wenn ich jetzt folgenden Code schreibe, also im &quot;Char-Verzeichnis&quot; unter Menüpunkt 3:</p>
<pre><code class="language-cpp">case 3:
						{
							cin.ignore(2);
							cout &lt;&lt; &quot;Menuepunkt(03) Suche nach einem Buchstaben in einem Satz\n&quot;;

							char String[10000];
							char *pString;
							char Buchstabe;

							cout &lt;&lt; &quot;Geben Sie einen String von weniger als 10000 Buchstaben ein!\n&quot;;
							cin.getline(String, 10000);

							cout &lt;&lt; &quot;Nach welchem Buchstaben soll gesucht werden?\n &quot;;
							cin  &gt;&gt; Buchstabe;

							pString = strchr(String, Buchstabe);

							while(pString!=NULL)
							{
								cout &lt;&lt; &quot;Gefunden an &quot; &lt;&lt; pString-String+1 &lt;&lt; &quot;\n&quot;;
								pString = strchr(pString+1, Buchstabe);
							}
							break;
						}
					case 4:
						{
							cin.ignore(3);
							cout &lt;&lt; &quot;Menuepunkt(04) Funktion getline\n&quot;;
							char name[256], titel[256];

							cout &lt;&lt; &quot;Geben Sie Ihren Namen ein:&quot;;
							cin.getline(name,256);

							cout &lt;&lt; &quot;Geben Sie Ihren Lieblingsfilm ein:&quot;;
							cin.getline(titel,256);

							cout &lt;&lt; name &lt;&lt; &quot;´s Lieblingsfilm ist &quot; &lt;&lt; titel &lt;&lt; &quot;\n&quot;;
							break;
						}
</code></pre>
<p>Dann bekomme ich keine Fehlermeldung.</p>
<p>Warum muss man denn</p>
<pre><code class="language-cpp">cin.getline(String, 10000);
</code></pre>
<p>schreiben?</p>
<p>Gruß Max</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2291243</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2291243</guid><dc:creator><![CDATA[silent_max]]></dc:creator><pubDate>Sat, 19 Jan 2013 09:37:36 GMT</pubDate></item><item><title><![CDATA[Reply to Char VS String on Sat, 19 Jan 2013 10:08:00 GMT]]></title><description><![CDATA[<p>Das zweite ist die Größe. Damit du nicht über die Grenzen des Puffers hinweg schreibst.</p>
<pre><code>char line[20];
std::cin.getline(line, 20); 
gets(line);
</code></pre>
<p>Was denkst du passiert bei dem Code jeweils wenn mehr als 20 Zeicheewn eingegeben werden?</p>
<p>Deswegen macht man es im Optimalfall mit std::string.</p>
<pre><code>std::string line;
std::getline(std::cin, line);
</code></pre>
<p>Da kann man beliebig viele Zeichen eingeben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2291253</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2291253</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Sat, 19 Jan 2013 10:08:00 GMT</pubDate></item><item><title><![CDATA[Reply to Char VS String on Sat, 19 Jan 2013 14:29:06 GMT]]></title><description><![CDATA[<p>Ersteinmal vielen Dank für die bisherigen Antworten.</p>
<p>Ethon schrieb:</p>
<blockquote>
<p>Das zweite ist die Größe. Damit du nicht über die Grenzen des Puffers hinweg schreibst.</p>
</blockquote>
<p>Haben wir etwas dazu gelernt.</p>
<p>Ethon schrieb:</p>
<blockquote>
<pre><code>char line[20];
std::cin.getline(line, 20); 
gets(line);
</code></pre>
<p>Was denkst du passiert bei dem Code jeweils wenn mehr als 20 Zeicheewn eingegeben werden?</p>
</blockquote>
<p>Also ich würde im Moment sagen, dass das Programm einen Overflow bekommt und nicht mehr funktioniert. Wobei man von den 20 deklarierten Zeichen 19 Zeichen eingeben kann, da das letzte Zeichen die binäre 0 ist (also '\0'). Habe ich das richtig verstanden??</p>
<p>Ethon schrieb:</p>
<blockquote>
<p>Deswegen macht man es im Optimalfall mit std::string.</p>
<pre><code>std::string line;
std::getline(std::cin, line);
</code></pre>
<p>Da kann man beliebig viele Zeichen eingeben.</p>
</blockquote>
<p>So wie ich Dich Ethon und die anderen Beteiligten verstehe, dann sollte man IMMER <code>std::string</code> verwenden? Ich weiß jetzt leider nicht mehr, wer es hier bei diesem Thread geschrieben hat, aber die Funktion <code>gets</code> sollte man laut Microsoft bzw. MSDN nicht mehr verwenden??</p>
<p>Dazu ein kleines Beispielprogramm:</p>
<pre><code class="language-cpp">#include&lt;iostream&gt;
#include&lt;string&gt;
using namespace std;

int main()
{
	string Text;

	cout &lt;&lt; &quot;Geben Sie einen weiteren Satz ein!\n&quot;;
	getline(cin, Text);

	cout &lt;&lt; &quot;Das haben Sie eingegeben: \n&quot;;
	cout &lt;&lt; Text &lt;&lt; &quot;\n&quot;;

	return 0;
}
</code></pre>
<p>Wäre das Beispielprogramm korrekt??</p>
<p>Gruß</p>
<p>Max</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2291314</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2291314</guid><dc:creator><![CDATA[silent_max]]></dc:creator><pubDate>Sat, 19 Jan 2013 14:29:06 GMT</pubDate></item><item><title><![CDATA[Reply to Char VS String on Sat, 19 Jan 2013 14:40:46 GMT]]></title><description><![CDATA[<p>silent_max schrieb:</p>
<blockquote>
<p>Also ich würde im Moment sagen, dass das Programm einen Overflow bekommt und nicht mehr funktioniert. Wobei man von den 20 deklarierten Zeichen 19 Zeichen eingeben kann, da das letzte Zeichen die binäre 0 ist (also '\0'). Habe ich das richtig verstanden??</p>
</blockquote>
<p>Genau, das mit gets ist verbuggt, das mit getline nicht.</p>
<p>[quote=&quot;silent_max&quot;]</p>
<p>Ethon schrieb:</p>
<blockquote>
<p>Deswegen macht man es im Optimalfall mit std::string.</p>
<pre><code>std::string line;
std::getline(std::cin, line);
</code></pre>
<p>Da kann man beliebig viele Zeichen eingeben.</p>
</blockquote>
<p>Exakt.</p>
<p>silent_max schrieb:</p>
<blockquote>
<p>So wie ich Dich Ethon und die anderen Beteiligten verstehe, dann sollte man IMMER <code>std::string</code> verwenden? Ich weiß jetzt leider nicht mehr, wer es hier bei diesem Thread geschrieben hat, aber die Funktion <code>gets</code> sollte man laut Microsoft bzw. MSDN nicht mehr verwenden??</p>
</blockquote>
<p>Es gibt Performancesonderfälle in denen man mit char Arrays anstatt std::string hantieren möchte, die sind aber für dich komplett irrelevant. <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>silent_max schrieb:</p>
<blockquote>
<p>Dazu ein kleines Beispielprogramm:</p>
<pre><code class="language-cpp">#include&lt;iostream&gt;
#include&lt;string&gt;
using namespace std;

int main()
{
	string Text;

	cout &lt;&lt; &quot;Geben Sie einen weiteren Satz ein!\n&quot;;
	getline(cin, Text);

	cout &lt;&lt; &quot;Das haben Sie eingegeben: \n&quot;;
	cout &lt;&lt; Text &lt;&lt; &quot;\n&quot;;

	return 0;
}
</code></pre>
<p>Wäre das Beispielprogramm korrekt??</p>
</blockquote>
<p>Ja, das ist korrekt so.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2291320</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2291320</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Sat, 19 Jan 2013 14:40:46 GMT</pubDate></item><item><title><![CDATA[Reply to Char VS String on Sat, 19 Jan 2013 15:51:07 GMT]]></title><description><![CDATA[<p>Langsam macht es Spaß zu programmieren... <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/2291346</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2291346</guid><dc:creator><![CDATA[silent_max]]></dc:creator><pubDate>Sat, 19 Jan 2013 15:51:07 GMT</pubDate></item></channel></rss>