<?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 replace]]></title><description><![CDATA[<p>hi,</p>
<p>ich lese eine Datei mit getline ein und möchte dort ein gefundenes Wort wie z.B: &quot;hallo&quot; mit einem anderen String replacen z.B &quot;hi&quot;.</p>
<p>[cpp]<br />
if(GetOperaCookie) {<br />
char szOp[256];<br />
sprintf(szOp, &quot;%s\\Folder01&quot;, folder);<br />
string zeile4;<br />
ifstream datei4(szOp);<br />
while(getline(datei4, zeile4)) {<br />
<strong>zeile4.replace(.......)</strong><br />
wie replace ich nun Hallo zu Hi?</p>
<p>}<br />
}<br />
[/cpp]</p>
<p>msg,lo</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/137003/string-replace</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Jul 2026 19:24:06 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/137003.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 14 Feb 2006 17:46:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to string replace on Tue, 14 Feb 2006 17:46:03 GMT]]></title><description><![CDATA[<p>hi,</p>
<p>ich lese eine Datei mit getline ein und möchte dort ein gefundenes Wort wie z.B: &quot;hallo&quot; mit einem anderen String replacen z.B &quot;hi&quot;.</p>
<p>[cpp]<br />
if(GetOperaCookie) {<br />
char szOp[256];<br />
sprintf(szOp, &quot;%s\\Folder01&quot;, folder);<br />
string zeile4;<br />
ifstream datei4(szOp);<br />
while(getline(datei4, zeile4)) {<br />
<strong>zeile4.replace(.......)</strong><br />
wie replace ich nun Hallo zu Hi?</p>
<p>}<br />
}<br />
[/cpp]</p>
<p>msg,lo</p>
]]></description><link>https://www.c-plusplus.net/forum/post/994171</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/994171</guid><dc:creator><![CDATA[str1]]></dc:creator><pubDate>Tue, 14 Feb 2006 17:46:03 GMT</pubDate></item><item><title><![CDATA[Reply to string replace on Tue, 14 Feb 2006 22:15:57 GMT]]></title><description><![CDATA[<p>Ich hab mal eine ANSI C Funktion geschrieben, die sogar nach Groß-/Kleinschreibung sucht und dynamisch Speicher reserviert, wenn der benötigt wird.</p>
<pre><code class="language-cpp">char* strreplace(char** str, char* sfind, char* sreplace, bool case_sensitivity)
{
	char* retval = (char*)NULL;
	char* tmpval = (char*)NULL;
	char* find = (char*)NULL;
	char* replace = (char*)NULL;
	unsigned long int pos = 0;
	unsigned long int len = 0;

	find = (char*)malloc((strlen(sfind)+1) * sizeof(char));
	strcpy(find, sfind);

	replace = (char*)malloc((strlen(sreplace)+1) * sizeof(char));
	strcpy(replace, sreplace);

	if(case_sensitivity)
	{
		tmpval = (char*)malloc((strlen(*str)+1) * sizeof(char));
		strcpy(tmpval, *str);
		strupr(tmpval);
		strupr(find);
	}

	retval = (char*)malloc(sizeof(char));

	len = strlen(*str);
	for (unsigned int i = 0; i &lt; len; i++)
	{
		if((!case_sensitivity &amp;&amp; strncmp(((*str)+i), find, strlen(find)) == 0)
				|| (case_sensitivity &amp;&amp; strncmp((tmpval+i), find, strlen(find)) == 0))
		{
			retval = (char*)realloc((char*)retval, (pos + strlen(replace) + 1) * sizeof(char));
			memcpy((retval+pos), replace, strlen(replace) * sizeof(char));
			pos = pos + strlen(replace);
			i += strlen(find)-1;
		}
		else
		{
			retval = (char*)realloc((char*)retval, (pos + 1 + 1) * sizeof(char));
			retval[pos] = *((*str)+i);
			pos++;
		}
	}
	retval[pos] = '\0';

	if(case_sensitivity)
		free(tmpval);

	free(find);
	free(replace);
	free(*str);
	*str = retval;
	return *str;
}
</code></pre>
<p>Gruß<br />
~code_pilot</p>
<p>PS: Gehört aber eigentlich nicht ins WinAPI-Forum!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/994416</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/994416</guid><dc:creator><![CDATA[code_pilot]]></dc:creator><pubDate>Tue, 14 Feb 2006 22:15:57 GMT</pubDate></item><item><title><![CDATA[Reply to string replace on Wed, 15 Feb 2006 00:52:42 GMT]]></title><description><![CDATA[<p>Und wie replace ich damit jetzt genau nen string?</p>
<p>string gay;<br />
strreplace(gay, &quot;hallo&quot;, &quot;hi&quot;, ..?);</p>
<p>Danke.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/994447</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/994447</guid><dc:creator><![CDATA[str]]></dc:creator><pubDate>Wed, 15 Feb 2006 00:52:42 GMT</pubDate></item><item><title><![CDATA[Reply to string replace on Thu, 16 Feb 2006 05:57:34 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">zeile4.replace(zeile4.find(&quot;Hallo&quot;, 0), 5, &quot;Hi&quot;);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/994465</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/994465</guid><dc:creator><![CDATA[luxx]]></dc:creator><pubDate>Thu, 16 Feb 2006 05:57:34 GMT</pubDate></item><item><title><![CDATA[Reply to string replace on Wed, 15 Feb 2006 23:04:45 GMT]]></title><description><![CDATA[<p>str schrieb:</p>
<blockquote>
<p>Und wie replace ich damit jetzt genau nen string?</p>
<p>string gay;<br />
strreplace(gay, &quot;hallo&quot;, &quot;hi&quot;, ..?);</p>
<p>Danke.</p>
</blockquote>
<p>ja</p>
<pre><code class="language-cpp">strreplace(ein_string_der_nicht_schwul_ist, &quot;hallo&quot;, &quot;hi&quot;, false);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/995348</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/995348</guid><dc:creator><![CDATA[code_pilot]]></dc:creator><pubDate>Wed, 15 Feb 2006 23:04:45 GMT</pubDate></item></channel></rss>