<?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[std::remove()]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich versuche mit std::remove() alle Leerzeichen eines Stringes vor dem ersten &quot;Nichtleerzeichen&quot; und nach dem letzten &quot;Nichtleerzeichen&quot; abzuscheiden.</p>
<p>Dies will jedoch nicht funktionieren, hier mein Sourcecode:</p>
<pre><code class="language-cpp">// Find the first position that is not a space
        string line = &quot;         hallo&quot;;
        unsigned short endPosition = 0;
        for (unsigned short i = 0; i &lt; line.length(); i++) {
            if (line[i] != ' ') {
                endPosition = i;
                break;
            }
        }
        if (endPosition &gt; 0) {
      //      cout &lt;&lt; *(line.begin() + endPosition) &lt;&lt; endl; // gibt &quot;h&quot; aus
            std::remove(line.begin(), (line.begin() + endPosition), ' ');
        }
</code></pre>
<p>Leider ändert sich nichts am string, seht ihr vielleicht das Problem/den Fehler?</p>
<p>Danke schon im voraus!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/264648/std-remove</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Sep 2026 14:30:17 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/264648.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 10 Apr 2010 16:05:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to std::remove() on Sat, 10 Apr 2010 16:05:42 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich versuche mit std::remove() alle Leerzeichen eines Stringes vor dem ersten &quot;Nichtleerzeichen&quot; und nach dem letzten &quot;Nichtleerzeichen&quot; abzuscheiden.</p>
<p>Dies will jedoch nicht funktionieren, hier mein Sourcecode:</p>
<pre><code class="language-cpp">// Find the first position that is not a space
        string line = &quot;         hallo&quot;;
        unsigned short endPosition = 0;
        for (unsigned short i = 0; i &lt; line.length(); i++) {
            if (line[i] != ' ') {
                endPosition = i;
                break;
            }
        }
        if (endPosition &gt; 0) {
      //      cout &lt;&lt; *(line.begin() + endPosition) &lt;&lt; endl; // gibt &quot;h&quot; aus
            std::remove(line.begin(), (line.begin() + endPosition), ' ');
        }
</code></pre>
<p>Leider ändert sich nichts am string, seht ihr vielleicht das Problem/den Fehler?</p>
<p>Danke schon im voraus!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1880623</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1880623</guid><dc:creator><![CDATA[Samyboy]]></dc:creator><pubDate>Sat, 10 Apr 2010 16:05:42 GMT</pubDate></item><item><title><![CDATA[Reply to std::remove() on Sat, 10 Apr 2010 16:11:29 GMT]]></title><description><![CDATA[<p>Tipp1: std::remove kopiert höchstens nur ein paar Elemente um. In Deinem Fall macht es so gut wie gar nichts (absichtlich)</p>
<p>Tipp2: Suchst Du vielleicht die erase-Methode von string?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1880627</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1880627</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Sat, 10 Apr 2010 16:11:29 GMT</pubDate></item><item><title><![CDATA[Reply to std::remove() on Sat, 10 Apr 2010 16:25:10 GMT]]></title><description><![CDATA[<p>Oder falls du es nur mit STL-Algorithmen machen willst:</p>
<pre><code class="language-cpp">bool not_space(char c)
{
    return c != ' ';
}

int main()
{
    std::string line = &quot;         hallo&quot;;
    std::string::iterator pos = std::find_if(line.begin(), line.end(), &amp;not_space);
    line.erase(line.begin(), pos);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1880631</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1880631</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Sat, 10 Apr 2010 16:25:10 GMT</pubDate></item><item><title><![CDATA[Reply to std::remove() on Sat, 10 Apr 2010 16:20:04 GMT]]></title><description><![CDATA[<p>krümelkacker schrieb:</p>
<blockquote>
<p>Tipp1: std::remove kopiert höchstens nur ein paar Elemente um. In Deinem Fall macht es so gut wie gar nichts (absichtlich)</p>
<p>Tipp2: Suchst Du vielleicht die erase-Methode von string?</p>
</blockquote>
<p>Dankeschön!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1880633</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1880633</guid><dc:creator><![CDATA[Samyboy]]></dc:creator><pubDate>Sat, 10 Apr 2010 16:20:04 GMT</pubDate></item><item><title><![CDATA[Reply to std::remove() on Sat, 10 Apr 2010 17:45:25 GMT]]></title><description><![CDATA[<p>Trim:</p>
<pre><code class="language-cpp">size_t trim;
	if( (trim = context.find_first_not_of( _T(&quot; \t&quot;) )) != wstring::npos )
		context.erase( 0, trim );
	if( (trim = context.find_last_not_of( _T(&quot; \t&quot;) )) != wstring::npos )
		context.resize( trim+1 );
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1880682</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1880682</guid><dc:creator><![CDATA[EOP]]></dc:creator><pubDate>Sat, 10 Apr 2010 17:45:25 GMT</pubDate></item></channel></rss>