<?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[Fehler: string subsricpt out of range]]></title><description><![CDATA[<p>Guten Abend,</p>
<p>ich habe ein Übungsprogramm geschrieben, bekomme bei der Ausgabe jedoch einen Fehler:</p>
<pre><code>string subsricpt out of range
</code></pre>
<pre><code class="language-cpp">// String-Aufteilung (Vor- und Nachn.).cpp : Definiert den Einstiegspunkt für die Konsolenanwendung.
//

#include &quot;stdafx.h&quot;
#include &lt;iostream&gt;
#include &lt;string&gt;

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
	int lengh, luecke;
	int i = 0;
	string vorname = &quot;&quot;;
	string nachname = &quot;&quot;;
	string name = &quot;Max Mustermann&quot;;

	cout &lt;&lt; &quot;Der Name ist &quot; &lt;&lt; name;

	// Zeichenlänge herausfinden &amp; 1. Leerzeichen suchen (Position)

	lengh = name.size(); // Länge von name wird in lengh1 gespeichert
	luecke = name.find(&quot; &quot;); // Position von der ersten Lücke wird gesucht

	cout &lt;&lt; endl &lt;&lt; &quot;Der Name ist &quot; &lt;&lt; lengh &lt;&lt; &quot; Buchstaben lang&quot;;

	// Vorname

	for(i = 0; i &lt; lengh; i++)
	{
		if(name[i] != 32)
		{
			vorname += name[i];
		}
		else break;
	}

	// Nachname

	for(i = luecke + 1; i != 32; i++)
	{
		if(name[i] != 32)
		{
			nachname += name[i];
		}
		else break;
	}

	// Ausgabe

	cout &lt;&lt; endl &lt;&lt; &quot;Der Vorname ist: &quot; &lt;&lt; vorname;
	cout &lt;&lt; endl &lt;&lt; &quot;Der Nachname ist: &quot; &lt;&lt; nachname;
	cout &lt;&lt; endl &lt;&lt; endl;

	return 0;
}
</code></pre>
<p>Ich habe das Programm eigentlich nur von einem Blatt aus der Schule abgeschrieben, dort hat es einwandfrei funktioniert. Habe es auch mal einer anderen Person zum testen geschickt (den Code), dort funktioniert es aucht.</p>
<p>Habt ihr vielleicht eine Idee, wo der Fehler liegt?</p>
<p>Vielen Dank.</p>
<p>f. G.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/218944/fehler-string-subsricpt-out-of-range</link><generator>RSS for Node</generator><lastBuildDate>Thu, 08 Oct 2026 13:27:01 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/218944.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 27 Jul 2008 16:30:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Fehler: string subsricpt out of range on Sun, 27 Jul 2008 16:30:49 GMT]]></title><description><![CDATA[<p>Guten Abend,</p>
<p>ich habe ein Übungsprogramm geschrieben, bekomme bei der Ausgabe jedoch einen Fehler:</p>
<pre><code>string subsricpt out of range
</code></pre>
<pre><code class="language-cpp">// String-Aufteilung (Vor- und Nachn.).cpp : Definiert den Einstiegspunkt für die Konsolenanwendung.
//

#include &quot;stdafx.h&quot;
#include &lt;iostream&gt;
#include &lt;string&gt;

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
	int lengh, luecke;
	int i = 0;
	string vorname = &quot;&quot;;
	string nachname = &quot;&quot;;
	string name = &quot;Max Mustermann&quot;;

	cout &lt;&lt; &quot;Der Name ist &quot; &lt;&lt; name;

	// Zeichenlänge herausfinden &amp; 1. Leerzeichen suchen (Position)

	lengh = name.size(); // Länge von name wird in lengh1 gespeichert
	luecke = name.find(&quot; &quot;); // Position von der ersten Lücke wird gesucht

	cout &lt;&lt; endl &lt;&lt; &quot;Der Name ist &quot; &lt;&lt; lengh &lt;&lt; &quot; Buchstaben lang&quot;;

	// Vorname

	for(i = 0; i &lt; lengh; i++)
	{
		if(name[i] != 32)
		{
			vorname += name[i];
		}
		else break;
	}

	// Nachname

	for(i = luecke + 1; i != 32; i++)
	{
		if(name[i] != 32)
		{
			nachname += name[i];
		}
		else break;
	}

	// Ausgabe

	cout &lt;&lt; endl &lt;&lt; &quot;Der Vorname ist: &quot; &lt;&lt; vorname;
	cout &lt;&lt; endl &lt;&lt; &quot;Der Nachname ist: &quot; &lt;&lt; nachname;
	cout &lt;&lt; endl &lt;&lt; endl;

	return 0;
}
</code></pre>
<p>Ich habe das Programm eigentlich nur von einem Blatt aus der Schule abgeschrieben, dort hat es einwandfrei funktioniert. Habe es auch mal einer anderen Person zum testen geschickt (den Code), dort funktioniert es aucht.</p>
<p>Habt ihr vielleicht eine Idee, wo der Fehler liegt?</p>
<p>Vielen Dank.</p>
<p>f. G.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1554681</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1554681</guid><dc:creator><![CDATA[Lionhead]]></dc:creator><pubDate>Sun, 27 Jul 2008 16:30:49 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler: string subsricpt out of range on Sun, 27 Jul 2008 16:50:24 GMT]]></title><description><![CDATA[<p>for(i = luecke + 1; i != 32; i++)<br />
{<br />
if(name[i] != 32)<br />
{<br />
nachname += name[i];<br />
}<br />
else break;<br />
}</p>
<p>sollte wohl i != length heißen, oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1554686</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1554686</guid><dc:creator><![CDATA[Maxi]]></dc:creator><pubDate>Sun, 27 Jul 2008 16:50:24 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler: string subsricpt out of range on Sun, 27 Jul 2008 17:07:08 GMT]]></title><description><![CDATA[<p>Oh, da habe ich mich wohl in der Zeile verguckt. Danke!</p>
<p>f. G.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1554694</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1554694</guid><dc:creator><![CDATA[Lionhead]]></dc:creator><pubDate>Sun, 27 Jul 2008 17:07:08 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler: string subsricpt out of range on Sun, 27 Jul 2008 17:53:42 GMT]]></title><description><![CDATA[<p>Ein kleiner Inhaltlicher Fehler:</p>
<pre><code class="language-cpp">cout &lt;&lt; endl &lt;&lt; &quot;Der Name ist &quot; &lt;&lt; lengh &lt;&lt; &quot; Buchstaben lang&quot;;
</code></pre>
<p>Dies gibt die Länge des Vor- und Nachnamens aus + das Leerzeichen...<br />
Außer du hast es so vorgesehen <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/1554714</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1554714</guid><dc:creator><![CDATA[Speedy_92]]></dc:creator><pubDate>Sun, 27 Jul 2008 17:53:42 GMT</pubDate></item></channel></rss>