<?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[hallo brauche hilfe bei Zeichen wechseln C++]]></title><description><![CDATA[<p>Schreiben Sie eine Funktion void Mod_String(...), welche eine beliebige Zeichenkette so verändert, dass sämtliche Zeichen, welche dem Parameter &quot;source&quot; entsprechen durch das Zeichen, welches dem Parameter &quot;dest&quot; entspricht, austauscht. Schreiben Sie nur die Funktion ohne das Hauptprogramm.</p>
<p>Beispiel: Urstring =&quot;Ja, es hat geklappt&quot; source='e' dest='a'<br />
Neuer String =&quot;Ja, as hat gaklappt&quot;</p>
<p>Danke im Voraus</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/220789/hallo-brauche-hilfe-bei-zeichen-wechseln-c</link><generator>RSS for Node</generator><lastBuildDate>Tue, 06 Oct 2026 17:03:21 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/220789.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 21 Aug 2008 08:32:24 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to hallo brauche hilfe bei Zeichen wechseln C++ on Thu, 21 Aug 2008 08:32:24 GMT]]></title><description><![CDATA[<p>Schreiben Sie eine Funktion void Mod_String(...), welche eine beliebige Zeichenkette so verändert, dass sämtliche Zeichen, welche dem Parameter &quot;source&quot; entsprechen durch das Zeichen, welches dem Parameter &quot;dest&quot; entspricht, austauscht. Schreiben Sie nur die Funktion ohne das Hauptprogramm.</p>
<p>Beispiel: Urstring =&quot;Ja, es hat geklappt&quot; source='e' dest='a'<br />
Neuer String =&quot;Ja, as hat gaklappt&quot;</p>
<p>Danke im Voraus</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1568703</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1568703</guid><dc:creator><![CDATA[rogi10]]></dc:creator><pubDate>Thu, 21 Aug 2008 08:32:24 GMT</pubDate></item><item><title><![CDATA[Reply to hallo brauche hilfe bei Zeichen wechseln C++ on Thu, 21 Aug 2008 08:34:13 GMT]]></title><description><![CDATA[<p>und was klappt nicht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1568707</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1568707</guid><dc:creator><![CDATA[zwutz]]></dc:creator><pubDate>Thu, 21 Aug 2008 08:34:13 GMT</pubDate></item><item><title><![CDATA[Reply to hallo brauche hilfe bei Zeichen wechseln C++ on Thu, 21 Aug 2008 09:20:18 GMT]]></title><description><![CDATA[<p>ja ich verstehe diese zwei befehle nicht hör e sie zum esrten mal kannst du mirn nicht mal das beispiel zeigen?</p>
<p>Beispiel: Urstring =&quot;Ja, es hat geklappt&quot; source='e' dest='a'<br />
Neuer String =&quot;Ja, as hat gaklappt&quot;</p>
<p>source='e' dest='a'</p>
<p>kein ahnung wie ich das erstellen sollte...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1568752</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1568752</guid><dc:creator><![CDATA[rogi10]]></dc:creator><pubDate>Thu, 21 Aug 2008 09:20:18 GMT</pubDate></item><item><title><![CDATA[Reply to hallo brauche hilfe bei Zeichen wechseln C++ on Thu, 21 Aug 2008 09:22:53 GMT]]></title><description><![CDATA[<p>rogi10 schrieb:</p>
<blockquote>
<p>ja ich verstehe diese zwei befehle nicht hör e sie zum esrten mal kannst du mirn nicht mal das beispiel zeigen?</p>
</blockquote>
<p>Das sind keine Befehle. Das ist ein Beispiel, was die Funktion tun soll, die du schreiben sollst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1568756</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1568756</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Thu, 21 Aug 2008 09:22:53 GMT</pubDate></item><item><title><![CDATA[Reply to hallo brauche hilfe bei Zeichen wechseln C++ on Thu, 21 Aug 2008 09:42:07 GMT]]></title><description><![CDATA[<p>Du sollst den Urstring zeichenweise durchgehen und wenn ein Buchstabe &quot;source&quot; entspricht, muss er durch den Buchstaben &quot;dest&quot; ersetzt werden. Wo ist das Problem? Zeig mal, was Du schon hast!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1568770</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1568770</guid><dc:creator><![CDATA[MiP]]></dc:creator><pubDate>Thu, 21 Aug 2008 09:42:07 GMT</pubDate></item><item><title><![CDATA[Reply to hallo brauche hilfe bei Zeichen wechseln C++ on Thu, 21 Aug 2008 09:49:02 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/18651">@MiP</a>: So einfach geht das leider nicht...<br />
Das ist der standard weg um sowas zu machen.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;algorithm&gt;

class replace_char
{
public:
   replace_char(char src, char dest)
   {
      destination = dest;
      source = src;
   }

   void operator()(char&amp; aChar)
   {
      if (aChar == source)
      {
         aChar = destination;
      }
   }
private:
   char destination;
   char source;
};

void Mod_string(char* string, char source, char dest)
{
   int length = strlen(string);
   std::for_each(string, string+length, replace_char(source, dest));
}

int main() 
{ 
   char string[] = &quot;Hallo&quot;;
   std::cout &lt;&lt; string &lt;&lt; std::endl;
   Mod_string(string, 'a', 'u');
   std::cout &lt;&lt; string &lt;&lt; std::endl;  
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1568775</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1568775</guid><dc:creator><![CDATA[templäd]]></dc:creator><pubDate>Thu, 21 Aug 2008 09:49:02 GMT</pubDate></item><item><title><![CDATA[Reply to hallo brauche hilfe bei Zeichen wechseln C++ on Thu, 21 Aug 2008 09:58:02 GMT]]></title><description><![CDATA[<p>Schönes Beispiel! Das kann er niemals beim Lehrer angeben. Der glaubt ihm nie im Leben, das selbst gemacht zu haben. Nebenbei war die Aufgabenstellung übrigens, das in <strong>einer</strong> Funktion zu erledigen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1568784</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1568784</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Thu, 21 Aug 2008 09:58:02 GMT</pubDate></item><item><title><![CDATA[Reply to hallo brauche hilfe bei Zeichen wechseln C++ on Thu, 21 Aug 2008 09:58:14 GMT]]></title><description><![CDATA[<p>oder die reine c variante</p>
<pre><code class="language-cpp">void replacechar(char* string, const char a, const char b)
{
    char* temp = string;

    if (!string) return;
    while (*temp) {
        if (*temp == a) *temp = b;
        temp++;
    }
    return;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1568786</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1568786</guid><dc:creator><![CDATA[sothis_]]></dc:creator><pubDate>Thu, 21 Aug 2008 09:58:14 GMT</pubDate></item><item><title><![CDATA[Reply to hallo brauche hilfe bei Zeichen wechseln C++ on Thu, 21 Aug 2008 10:04:44 GMT]]></title><description><![CDATA[<p>oder als 1-Zeiler:</p>
<pre><code class="language-cpp">void Mod_string(char* string, char source, char dest)
{
	for (int i(0);i&lt;strlen(string);++i) if (string[i]==source) string[i]=dest;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1568790</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1568790</guid><dc:creator><![CDATA[MiP]]></dc:creator><pubDate>Thu, 21 Aug 2008 10:04:44 GMT</pubDate></item><item><title><![CDATA[Reply to hallo brauche hilfe bei Zeichen wechseln C++ on Thu, 21 Aug 2008 11:52:16 GMT]]></title><description><![CDATA[<p>_matze schrieb:</p>
<blockquote>
<p>Schönes Beispiel! Das kann er niemals beim Lehrer angeben. Der glaubt ihm nie im Leben, das selbst gemacht zu haben.</p>
</blockquote>
<p>Ich glaub darum ging es in der Antwort.</p>
<blockquote>
<p>Nebenbei war die Aufgabenstellung übrigens, das in <strong>einer</strong> Funktion zu erledigen.</p>
</blockquote>
<p>Dann eben</p>
<pre><code class="language-cpp">void Mod_string(char* string, char source, char dest)
{
	class replace_char
	{
	public:
		replace_char(const char src, const char dest)
		: source(src), destination(dest)
		{ }

		void operator()(char&amp; aChar)
		{
		  if (aChar == source) {
			 aChar = destination;
		  }
		}
	private:
		const char destination;
		const char source;
	};

   int length = strlen(string);
   std::for_each(string, string+length, replace_char(source, dest));
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1568853</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1568853</guid><dc:creator><![CDATA[DerKuchen]]></dc:creator><pubDate>Thu, 21 Aug 2008 11:52:16 GMT</pubDate></item><item><title><![CDATA[Reply to hallo brauche hilfe bei Zeichen wechseln C++ on Thu, 21 Aug 2008 12:10:31 GMT]]></title><description><![CDATA[<p>DerKuchen schrieb:</p>
<blockquote>
<p>_matze schrieb:</p>
<blockquote>
<p>Schönes Beispiel! Das kann er niemals beim Lehrer angeben. Der glaubt ihm nie im Leben, das selbst gemacht zu haben.</p>
</blockquote>
<p>Ich glaub darum ging es in der Antwort.</p>
</blockquote>
<p>Das war mir schon klar. Ich wollte dem auch beipflichten! Da vergisst man ein mal die blöden Smileys... <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/1568864</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1568864</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Thu, 21 Aug 2008 12:10:31 GMT</pubDate></item><item><title><![CDATA[Reply to hallo brauche hilfe bei Zeichen wechseln C++ on Thu, 21 Aug 2008 12:21:33 GMT]]></title><description><![CDATA[<p>Warum sich mit for_each abmühen?</p>
<pre><code class="language-cpp">void Mod_String( std::string&amp; s, char source, char dest )
{
    std::replace( s.begin(), s.end(), source, dest );
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1568874</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1568874</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Thu, 21 Aug 2008 12:21:33 GMT</pubDate></item><item><title><![CDATA[Reply to hallo brauche hilfe bei Zeichen wechseln C++ on Thu, 21 Aug 2008 12:22:02 GMT]]></title><description><![CDATA[<p>DerKuchen schrieb:</p>
<blockquote>
<p>Dann eben</p>
<pre><code class="language-cpp">void Mod_string(char* string, char source, char dest)
{
	class replace_char
	{
	public:
		replace_char(const char src, const char dest)
		: source(src), destination(dest)
		{ }

		void operator()(char&amp; aChar)
		{
		  if (aChar == source) {
			 aChar = destination;
		  }
		}
	private:
		const char destination;
		const char source;
	};

   int length = strlen(string);
   std::for_each(string, string+length, replace_char(source, dest));
}
</code></pre>
</blockquote>
<p>ISO/IEC 14882:2003 schrieb:</p>
<blockquote>
<p>14.3.1 §2<br />
A local type, a type with no linkage, an unnamed type or a type compounded from any of these types shall not be used as a template-argument for a template type-parameter.</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1568875</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1568875</guid><dc:creator><![CDATA[Tachyon]]></dc:creator><pubDate>Thu, 21 Aug 2008 12:22:02 GMT</pubDate></item><item><title><![CDATA[Reply to hallo brauche hilfe bei Zeichen wechseln C++ on Thu, 21 Aug 2008 13:31:40 GMT]]></title><description><![CDATA[<p>Tachyon schrieb:</p>
<blockquote>
<p>ISO/IEC 14882:2003 schrieb:</p>
<blockquote>
<p>14.3.1 §2<br />
A local type, a type with no linkage, an unnamed type or a type compounded from any of these types shall not be used as a template-argument for a template type-parameter.</p>
</blockquote>
</blockquote>
<p>Und wenn ich Bitte sage?</p>
<p>Dann muss man eben doch die langweilige Version mit std::replace nehmen *seufz*</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1568927</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1568927</guid><dc:creator><![CDATA[DerKuchen]]></dc:creator><pubDate>Thu, 21 Aug 2008 13:31:40 GMT</pubDate></item><item><title><![CDATA[Reply to hallo brauche hilfe bei Zeichen wechseln C++ on Thu, 21 Aug 2008 13:34:17 GMT]]></title><description><![CDATA[<p>DerKuchen schrieb:</p>
<blockquote>
<p>Dann muss man eben doch die langweilige Version mit std::replace nehmen *seufz*</p>
</blockquote>
<p>Kannst sie ja ein bißchen aufbohren:</p>
<pre><code class="language-cpp">replace_if( s.begin(), s.end(), bind1st( equal_to&lt;char&gt;(), source ), dest );
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1568930</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1568930</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Thu, 21 Aug 2008 13:34:17 GMT</pubDate></item><item><title><![CDATA[Reply to hallo brauche hilfe bei Zeichen wechseln C++ on Thu, 21 Aug 2008 13:39:09 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">void replace(char* lll, char ll1, char l11){
  do *lll = *lll == ll1 ? l11 : *lll; while (*(lll++));
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1568934</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1568934</guid><dc:creator><![CDATA[Fellhuhn]]></dc:creator><pubDate>Thu, 21 Aug 2008 13:39:09 GMT</pubDate></item><item><title><![CDATA[Reply to hallo brauche hilfe bei Zeichen wechseln C++ on Thu, 21 Aug 2008 13:48:25 GMT]]></title><description><![CDATA[<p>Fellhuhn schrieb:</p>
<blockquote>
<pre><code class="language-cpp">void replace(char* lll, char ll1, char l11){
  do *lll = *lll == ll1 ? l11 : *lll; while (*(lll++));
}
</code></pre>
</blockquote>
<p>Hehe, und das am Besten noch als Makro...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1568947</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1568947</guid><dc:creator><![CDATA[Tachyon]]></dc:creator><pubDate>Thu, 21 Aug 2008 13:48:25 GMT</pubDate></item><item><title><![CDATA[Reply to hallo brauche hilfe bei Zeichen wechseln C++ on Thu, 21 Aug 2008 13:56:24 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">void replace(char* i, char í, char ì){
  while((*i^í||(*i^=í^ì))&amp;&amp;*i++);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1568953</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1568953</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Thu, 21 Aug 2008 13:56:24 GMT</pubDate></item><item><title><![CDATA[Reply to hallo brauche hilfe bei Zeichen wechseln C++ on Thu, 21 Aug 2008 13:58:06 GMT]]></title><description><![CDATA[<p>omg, jetzt gehts los</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1568955</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1568955</guid><dc:creator><![CDATA[sothis_]]></dc:creator><pubDate>Thu, 21 Aug 2008 13:58:06 GMT</pubDate></item><item><title><![CDATA[Reply to hallo brauche hilfe bei Zeichen wechseln C++ on Thu, 21 Aug 2008 14:05:40 GMT]]></title><description><![CDATA[<p>Da wir alle etwas um die Performance besorgt sind, ein wenig Loop Unrolling:</p>
<pre><code class="language-cpp">void Mod_string(char *str, char src, char dest)
{
	int n = (strlen(str) + 7) / 8;

	switch (n % 8) {
		case 0: do { *str = *str == src ? dest : *str; str++; 
		case 7:      *str = *str == src ? dest : *str; str++;
		case 6:      *str = *str == src ? dest : *str; str++;
		case 5:      *str = *str == src ? dest : *str; str++;
		case 4:      *str = *str == src ? dest : *str; str++;
		case 3:      *str = *str == src ? dest : *str; str++;
		case 2:      *str = *str == src ? dest : *str; str++;
		case 1:      *str = *str == src ? dest : *str; str++;
				} while (--n &gt; 0);
	}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1568961</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1568961</guid><dc:creator><![CDATA[DerKuchen]]></dc:creator><pubDate>Thu, 21 Aug 2008 14:05:40 GMT</pubDate></item></channel></rss>