<?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[String mit Teilen durch &amp;quot;&#x5C;n&amp;quot; getrennt in system() ausführen]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich bekomme es seit Stunden nicht hin, ein einfaches Programm zu schreiben, dass einen String in system() ausführt. Der String könnte so lauten: &quot;mspaint.exe\nnotepad.exe\ncmd.exe&quot;<br />
Dazu muss ja einfach vor jedem &quot;\n&quot; der Inhalt ausgeführt werden.<br />
Überlegt habe ich mir:</p>
<pre><code class="language-cpp">string str = &quot;mspaint.exe\nnotepad.exe\ncmd.exe&quot;;

while(str.find(&quot;\n&quot;) != string::npos){
		system(str.substr(0, str.find(&quot;\n&quot;)).c_str());
		str.erase(0, str.find(&quot;\n&quot;));
	}
</code></pre>
<p>Aber das klappt nicht und ich bekomme nur &quot;mspaint.exe&quot; ausgeführt. Außerdem wird str dabei verändert, was aber nicht soll.<br />
Bin für jede Hilfe dankbar!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/258962/string-mit-teilen-durch-quot-n-quot-getrennt-in-system-ausführen</link><generator>RSS for Node</generator><lastBuildDate>Wed, 09 Sep 2026 02:21:12 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/258962.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 17 Jan 2010 16:41:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to String mit Teilen durch &amp;quot;&#x5C;n&amp;quot; getrennt in system() ausführen on Sun, 17 Jan 2010 16:41:31 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich bekomme es seit Stunden nicht hin, ein einfaches Programm zu schreiben, dass einen String in system() ausführt. Der String könnte so lauten: &quot;mspaint.exe\nnotepad.exe\ncmd.exe&quot;<br />
Dazu muss ja einfach vor jedem &quot;\n&quot; der Inhalt ausgeführt werden.<br />
Überlegt habe ich mir:</p>
<pre><code class="language-cpp">string str = &quot;mspaint.exe\nnotepad.exe\ncmd.exe&quot;;

while(str.find(&quot;\n&quot;) != string::npos){
		system(str.substr(0, str.find(&quot;\n&quot;)).c_str());
		str.erase(0, str.find(&quot;\n&quot;));
	}
</code></pre>
<p>Aber das klappt nicht und ich bekomme nur &quot;mspaint.exe&quot; ausgeführt. Außerdem wird str dabei verändert, was aber nicht soll.<br />
Bin für jede Hilfe dankbar!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1840285</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840285</guid><dc:creator><![CDATA[MitNase]]></dc:creator><pubDate>Sun, 17 Jan 2010 16:41:31 GMT</pubDate></item><item><title><![CDATA[Reply to String mit Teilen durch &amp;quot;&#x5C;n&amp;quot; getrennt in system() ausführen on Sun, 17 Jan 2010 17:05:07 GMT]]></title><description><![CDATA[<p><a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39453.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-39453.html</a></p>
<p>Verwende lieber <a href="http://msdn.microsoft.com/en-us/library/bb762153.aspx" rel="nofollow">ShellExecute</a> aus der WinAPI.</p>
<p>Grüssli</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1840311</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840311</guid><dc:creator><![CDATA[Dravere]]></dc:creator><pubDate>Sun, 17 Jan 2010 17:05:07 GMT</pubDate></item><item><title><![CDATA[Reply to String mit Teilen durch &amp;quot;&#x5C;n&amp;quot; getrennt in system() ausführen on Sun, 17 Jan 2010 17:08:03 GMT]]></title><description><![CDATA[<p>Danke für deine Hilfe! Soll aber auch unter Linux funktionieren. str kann auch den Wert &quot;/bin/sh\nifconfig&quot; haben. Weiß da jemand was?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1840315</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840315</guid><dc:creator><![CDATA[MitNase]]></dc:creator><pubDate>Sun, 17 Jan 2010 17:08:03 GMT</pubDate></item><item><title><![CDATA[Reply to String mit Teilen durch &amp;quot;&#x5C;n&amp;quot; getrennt in system() ausführen on Sun, 17 Jan 2010 17:29:17 GMT]]></title><description><![CDATA[<p>Wenn ich mich nicht irre, funktioniert system() auch nur auf Windows.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1840329</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840329</guid><dc:creator><![CDATA[freaky]]></dc:creator><pubDate>Sun, 17 Jan 2010 17:29:17 GMT</pubDate></item><item><title><![CDATA[Reply to String mit Teilen durch &amp;quot;&#x5C;n&amp;quot; getrennt in system() ausführen on Sun, 17 Jan 2010 17:33:10 GMT]]></title><description><![CDATA[<p>FreakY&lt;3Cpp schrieb:</p>
<blockquote>
<p>Wenn ich mich nicht irre, funktioniert system() auch nur auf Windows.</p>
</blockquote>
<p>Nicht. <a href="http://www.cplusplus.com/reference/clibrary/cstdlib/system/" rel="nofollow">http://www.cplusplus.com/reference/clibrary/cstdlib/system/</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1840332</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840332</guid><dc:creator><![CDATA[MitNase]]></dc:creator><pubDate>Sun, 17 Jan 2010 17:33:10 GMT</pubDate></item><item><title><![CDATA[Reply to String mit Teilen durch &amp;quot;&#x5C;n&amp;quot; getrennt in system() ausführen on Sun, 17 Jan 2010 17:40:29 GMT]]></title><description><![CDATA[<p>Eigentlich eine ganz einfache Sache...</p>
<pre><code class="language-cpp">#include &lt;sstream&gt;
#include &lt;string&gt;
#include &lt;iostream&gt;

int main() {
	std::string str = &quot;mspaint.exe\nnotepad.exe\ncmd.exe&quot;;
	std::stringstream ss(str);
	if(!ss) {
		// Fehler...
	}
	std::string cmd;
	while(ss &gt;&gt; cmd)
		system(cmd.c_str());
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1840338</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840338</guid><dc:creator><![CDATA[Ad aCTa]]></dc:creator><pubDate>Sun, 17 Jan 2010 17:40:29 GMT</pubDate></item><item><title><![CDATA[Reply to String mit Teilen durch &amp;quot;&#x5C;n&amp;quot; getrennt in system() ausführen on Sun, 17 Jan 2010 17:41:57 GMT]]></title><description><![CDATA[<blockquote>
<p>returning an int value, whose interpretation is system-dependent.</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1840340</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840340</guid><dc:creator><![CDATA[freaky]]></dc:creator><pubDate>Sun, 17 Jan 2010 17:41:57 GMT</pubDate></item><item><title><![CDATA[Reply to String mit Teilen durch &amp;quot;&#x5C;n&amp;quot; getrennt in system() ausführen on Sun, 17 Jan 2010 17:44:54 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">...
std::stringstream ss(str);
...
</code></pre>
<p>Dankeschön! Mein Compiler sagt dazu aber:</p>
<pre><code>error: variable `std::stringstream ss' has initializer but incomplete type
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1840344</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840344</guid><dc:creator><![CDATA[MitNase]]></dc:creator><pubDate>Sun, 17 Jan 2010 17:44:54 GMT</pubDate></item><item><title><![CDATA[Reply to String mit Teilen durch &amp;quot;&#x5C;n&amp;quot; getrennt in system() ausführen on Sun, 17 Jan 2010 17:46:47 GMT]]></title><description><![CDATA[<p>Uups, hab vergessen &lt;sstream&gt; zu includieren. Nehme alles zurück.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1840346</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840346</guid><dc:creator><![CDATA[MitNase]]></dc:creator><pubDate>Sun, 17 Jan 2010 17:46:47 GMT</pubDate></item><item><title><![CDATA[Reply to String mit Teilen durch &amp;quot;&#x5C;n&amp;quot; getrennt in system() ausführen on Sun, 17 Jan 2010 18:02:33 GMT]]></title><description><![CDATA[<p>Ad aCTa schrieb:</p>
<blockquote>
<p>Eigentlich eine ganz einfache Sache...</p>
<pre><code class="language-cpp">#include &lt;sstream&gt;
#include &lt;string&gt;
#include &lt;iostream&gt;

int main() {
	std::string str = &quot;mspaint.exe\nnotepad.exe\ncmd.exe&quot;;
	std::stringstream ss(str);
	if(!ss) {
		// Fehler...
	}
	std::string cmd;
	while(ss &gt;&gt; cmd)
		system(cmd.c_str());
}
</code></pre>
</blockquote>
<p>Hab grad bemerkt, dass ich damit kein &quot;echo bla&quot; machen kann. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title="=("
      alt="😞"
    /><br />
Er führt sowohl &quot;echo&quot; als auch &quot;bla&quot; als Befehl aus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1840355</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840355</guid><dc:creator><![CDATA[MitNase]]></dc:creator><pubDate>Sun, 17 Jan 2010 18:02:33 GMT</pubDate></item><item><title><![CDATA[Reply to String mit Teilen durch &amp;quot;&#x5C;n&amp;quot; getrennt in system() ausführen on Sun, 17 Jan 2010 19:22:14 GMT]]></title><description><![CDATA[<p>Es könnte helfen, die Befehle nicht durch \n zu trennen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1840389</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840389</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Sun, 17 Jan 2010 19:22:14 GMT</pubDate></item><item><title><![CDATA[Reply to String mit Teilen durch &amp;quot;&#x5C;n&amp;quot; getrennt in system() ausführen on Sun, 17 Jan 2010 19:25:34 GMT]]></title><description><![CDATA[<p>Also bei mir geht das so:</p>
<pre><code class="language-cpp">#include &lt;string&gt;
#include &lt;stdlib.h&gt;

int main(int argc, char* argv[])
{
  std::string cmd = &quot;ifconfig\neth0&quot;;
  std::string::size_type p;
  while ( (p = cmd.find('\n')) != std::string::npos)
    cmd[p] = ' ';
  system(cmd.c_str());
}
</code></pre>
<p>Ich habe übrigens Linux.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1840392</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840392</guid><dc:creator><![CDATA[tntnet]]></dc:creator><pubDate>Sun, 17 Jan 2010 19:25:34 GMT</pubDate></item><item><title><![CDATA[Reply to String mit Teilen durch &amp;quot;&#x5C;n&amp;quot; getrennt in system() ausführen on Sun, 17 Jan 2010 19:31:20 GMT]]></title><description><![CDATA[<p>Die Befehle werden Zwangsweise durch \n getrennt, da ich sie aus einer Textdatei lese. Ich habe das Beispiel nur aufs Wesentliche beschränkt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1840394</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840394</guid><dc:creator><![CDATA[MitNase]]></dc:creator><pubDate>Sun, 17 Jan 2010 19:31:20 GMT</pubDate></item><item><title><![CDATA[Reply to String mit Teilen durch &amp;quot;&#x5C;n&amp;quot; getrennt in system() ausführen on Sun, 17 Jan 2010 20:40:37 GMT]]></title><description><![CDATA[<p>MitNase schrieb:</p>
<blockquote>
<p>Die Befehle werden Zwangsweise durch \n getrennt, da ich sie aus einer Textdatei lese. Ich habe das Beispiel nur aufs Wesentliche beschränkt.</p>
</blockquote>
<p>Dann lies sie anders aus der Textdatei. Du hast sie nicht aufs wesentliche beschränkt sondern noch weiter, das Detail mit der Textdatei wäre wichtig gewesen.<br />
Siehe den Link in meiner Signatur, Teil &quot;Sag was du erreichen willst, nicht wie du es erreichen willst&quot;.<br />
Was du erreichen willst wäre hier gewesen &quot;ich will einzelne Zeilen einer Textdatei als Shellkommandos (Win und Linux) ausführen.&quot;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1840441</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840441</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Sun, 17 Jan 2010 20:40:37 GMT</pubDate></item><item><title><![CDATA[Reply to String mit Teilen durch &amp;quot;&#x5C;n&amp;quot; getrennt in system() ausführen on Sun, 17 Jan 2010 21:09:51 GMT]]></title><description><![CDATA[<p>pumuckl schrieb:</p>
<blockquote>
<p>MitNase schrieb:</p>
<blockquote>
<p>Die Befehle werden Zwangsweise durch \n getrennt, da ich sie aus einer Textdatei lese. Ich habe das Beispiel nur aufs Wesentliche beschränkt.</p>
</blockquote>
<p>Dann lies sie anders aus der Textdatei. Du hast sie nicht aufs wesentliche beschränkt sondern noch weiter, das Detail mit der Textdatei wäre wichtig gewesen.<br />
Siehe den Link in meiner Signatur, Teil &quot;Sag was du erreichen willst, nicht wie du es erreichen willst&quot;.<br />
Was du erreichen willst wäre hier gewesen &quot;ich will einzelne Zeilen einer Textdatei als Shellkommandos (Win und Linux) ausführen.&quot;</p>
</blockquote>
<p>Ok, tut mir leid. <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="🙂"
    /> Weißt du trotzdem wie ich meinen String, den ich bereits aus der Textdatei gelesen hab ausführen kann?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1840452</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840452</guid><dc:creator><![CDATA[MitNase]]></dc:creator><pubDate>Sun, 17 Jan 2010 21:09:51 GMT</pubDate></item><item><title><![CDATA[Reply to String mit Teilen durch &amp;quot;&#x5C;n&amp;quot; getrennt in system() ausführen on Sun, 17 Jan 2010 21:20:10 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;fstream&gt;
#include &lt;string&gt;
#include &lt;iostream&gt;

int main() {
	std::ifstream ifs(&quot;commands.txt&quot;, std::ios_base::binary);
    if(!ifs) {
        // Fehler...
    }
    std::string cmd;
	while(std::getline(ifs, cmd))
        system(cmd.c_str());
}
</code></pre>
<p>Wo ist denn das Problem?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1840455</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840455</guid><dc:creator><![CDATA[Ad aCTa]]></dc:creator><pubDate>Sun, 17 Jan 2010 21:20:10 GMT</pubDate></item><item><title><![CDATA[Reply to String mit Teilen durch &amp;quot;&#x5C;n&amp;quot; getrennt in system() ausführen on Sun, 17 Jan 2010 21:28:25 GMT]]></title><description><![CDATA[<p>Ad aCTa schrieb:</p>
<blockquote>
<p>Wo ist denn das Problem?</p>
</blockquote>
<p>Wahrscheinlich ganz einfach. Ein std::system Aufruf blockiert, bis das Programm fertig ist, welches ausgeführt wurde.<br />
Anders gesagt, werden die Programme nacheinander ausgeführt und nicht gleichzeitig gestartet.</p>
<p>Grüssli</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1840459</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840459</guid><dc:creator><![CDATA[Dravere]]></dc:creator><pubDate>Sun, 17 Jan 2010 21:28:25 GMT</pubDate></item><item><title><![CDATA[Reply to String mit Teilen durch &amp;quot;&#x5C;n&amp;quot; getrennt in system() ausführen on Sun, 17 Jan 2010 21:42:32 GMT]]></title><description><![CDATA[<p>Ad aCTa schrieb:</p>
<blockquote>
<pre><code class="language-cpp">#include &lt;fstream&gt;
#include &lt;string&gt;
#include &lt;iostream&gt;

int main() {
	std::ifstream ifs(&quot;commands.txt&quot;, std::ios_base::binary);
    if(!ifs) {
        // Fehler...
    }
    std::string cmd;
	while(std::getline(ifs, cmd))
        system(cmd.c_str());
}
</code></pre>
<p>Wo ist denn das Problem?</p>
</blockquote>
<p>Danke für deine Hilfe. Das Problem ist, dass die Datei schon als String gebuffert ist. Aus einer anderen Quelle. Ansonsten müsste ich die den Inhalt des Strings als Datei speichern und anschließend wieder öffnen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1840466</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840466</guid><dc:creator><![CDATA[MitNase]]></dc:creator><pubDate>Sun, 17 Jan 2010 21:42:32 GMT</pubDate></item><item><title><![CDATA[Reply to String mit Teilen durch &amp;quot;&#x5C;n&amp;quot; getrennt in system() ausführen on Sun, 17 Jan 2010 21:46:33 GMT]]></title><description><![CDATA[<p>Und wieso ist das ein Problem, dass du die Kommandos als String hast?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1840472</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840472</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Sun, 17 Jan 2010 21:46:33 GMT</pubDate></item><item><title><![CDATA[Reply to String mit Teilen durch &amp;quot;&#x5C;n&amp;quot; getrennt in system() ausführen on Sun, 17 Jan 2010 21:47:17 GMT]]></title><description><![CDATA[<p>MitNase schrieb:</p>
<blockquote>
<p>Danke für deine Hilfe. Das Problem ist, dass die Datei schon als String gebuffert ist. Aus einer anderen Quelle. Ansonsten müsste ich die den Inhalt des Strings als Datei speichern und anschließend wieder öffnen.</p>
</blockquote>
<p>Du kannst auch einen<a href="http://www.cplusplus.com/reference/iostream/istringstream/" rel="nofollow"> <code>istringstream</code> </a>verwenden:</p>
<pre><code class="language-cpp">#include &lt;string&gt;
#include &lt;sstream&gt;

int main()
{
  std::string buffer = &quot;hello\nworld\nthis\nwhatever&quot;;
  std::istringstream iss(buffer);

  std::string line;
  while(std::getline(iss, line))
  {
    // mach was mit line ...
  }

  return 0;
}
</code></pre>
<p>Könntest das ganze natürlich auch in Tokens aufteilen mit<a href="http://www.cplusplus.com/reference/string/string/find/" rel="nofollow"> <code>std::string::find</code> </a>und<a href="http://www.cplusplus.com/reference/string/string/substr/" rel="nofollow"> <code>std::string::substr</code> </a>.</p>
<p>Grüssli</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1840473</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840473</guid><dc:creator><![CDATA[Dravere]]></dc:creator><pubDate>Sun, 17 Jan 2010 21:47:17 GMT</pubDate></item><item><title><![CDATA[Reply to String mit Teilen durch &amp;quot;&#x5C;n&amp;quot; getrennt in system() ausführen on Sun, 17 Jan 2010 21:48:08 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>Und wieso ist das ein Problem, dass du die Kommandos als String hast?</p>
</blockquote>
<p>Dass getline char verlangt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1840474</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840474</guid><dc:creator><![CDATA[MitNase]]></dc:creator><pubDate>Sun, 17 Jan 2010 21:48:08 GMT</pubDate></item><item><title><![CDATA[Reply to String mit Teilen durch &amp;quot;&#x5C;n&amp;quot; getrennt in system() ausführen on Sun, 17 Jan 2010 22:01:30 GMT]]></title><description><![CDATA[<p>MitNase schrieb:</p>
<blockquote>
<p>SeppJ schrieb:</p>
<blockquote>
<p>Und wieso ist das ein Problem, dass du die Kommandos als String hast?</p>
</blockquote>
<p>Dass getline char verlangt.</p>
</blockquote>
<p>Nicht wenn du die freie<a href="http://www.cplusplus.com/reference/string/getline/" rel="nofollow"> <code>std::getline</code> </a>Funktion verwendest, welche sich im Header &lt;string&gt; befindet.</p>
<p>Grüssli</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1840479</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840479</guid><dc:creator><![CDATA[Dravere]]></dc:creator><pubDate>Sun, 17 Jan 2010 22:01:30 GMT</pubDate></item><item><title><![CDATA[Reply to String mit Teilen durch &amp;quot;&#x5C;n&amp;quot; getrennt in system() ausführen on Sun, 17 Jan 2010 22:02:53 GMT]]></title><description><![CDATA[<p>Dravere schrieb:</p>
<blockquote>
<p>MitNase schrieb:</p>
<blockquote>
<p>Danke für deine Hilfe. Das Problem ist, dass die Datei schon als String gebuffert ist. Aus einer anderen Quelle. Ansonsten müsste ich die den Inhalt des Strings als Datei speichern und anschließend wieder öffnen.</p>
</blockquote>
<p>Du kannst auch einen<a href="http://www.cplusplus.com/reference/iostream/istringstream/" rel="nofollow"> <code>istringstream</code> </a>verwenden:</p>
<pre><code class="language-cpp">#include &lt;string&gt;
#include &lt;sstream&gt;

int main()
{
  std::string buffer = &quot;hello\nworld\nthis\nwhatever&quot;;
  std::istringstream iss(buffer);

  std::string line;
  while(std::getline(iss, line))
  {
    // mach was mit line ...
  }

  return 0;
}
</code></pre>
<p>Könntest das ganze natürlich auch in Tokens aufteilen mit<a href="http://www.cplusplus.com/reference/string/string/find/" rel="nofollow"> <code>std::string::find</code> </a>und<a href="http://www.cplusplus.com/reference/string/string/substr/" rel="nofollow"> <code>std::string::substr</code> </a>.</p>
<p>Grüssli</p>
</blockquote>
<p>Endlich mal was, was funktioniert! Tausend++ Dank!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1840481</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1840481</guid><dc:creator><![CDATA[MitNase]]></dc:creator><pubDate>Sun, 17 Jan 2010 22:02:53 GMT</pubDate></item></channel></rss>