<?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[Replace]]></title><description><![CDATA[<p>Hallo liebe C/C++ Community,<br />
Ich bin neu in C und wollte mal fragen wie man in C einen bestimmten txt ersetzt ich weiß wie man die Datei einliest nur leider weiß ich nicht wie man was ersetzt z.b. in Perl gibt es die methode &quot;Pattern&quot; in PHP &quot;str_replace&quot;. Wie könnte es in C aussehen?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/131528/replace</link><generator>RSS for Node</generator><lastBuildDate>Thu, 27 Aug 2026 03:51:09 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/131528.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 04 Jan 2006 10:29:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Replace on Wed, 04 Jan 2006 10:29:50 GMT]]></title><description><![CDATA[<p>Hallo liebe C/C++ Community,<br />
Ich bin neu in C und wollte mal fragen wie man in C einen bestimmten txt ersetzt ich weiß wie man die Datei einliest nur leider weiß ich nicht wie man was ersetzt z.b. in Perl gibt es die methode &quot;Pattern&quot; in PHP &quot;str_replace&quot;. Wie könnte es in C aussehen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/956398</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/956398</guid><dc:creator><![CDATA[cyberdevil87]]></dc:creator><pubDate>Wed, 04 Jan 2006 10:29:50 GMT</pubDate></item><item><title><![CDATA[Reply to Replace on Wed, 04 Jan 2006 10:32:13 GMT]]></title><description><![CDATA[<p>c oder c++?</p>
<p>text? char oder string(wenn wirklich c++)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/956403</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/956403</guid><dc:creator><![CDATA[ser1al]]></dc:creator><pubDate>Wed, 04 Jan 2006 10:32:13 GMT</pubDate></item><item><title><![CDATA[Reply to Replace on Wed, 04 Jan 2006 10:32:26 GMT]]></title><description><![CDATA[<p>std::string hat die Methoden find() (um dein Muster zu finden) und replace() (um einen Teilstring auszutauschen) - zusammenbauen mußt du dir das schon selber.</p>
<p>(genauso benötigst du etwas handgeschriebenes, wenn du reguläre Ausdrücke finden und ersetzen willst)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/956404</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/956404</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 04 Jan 2006 10:32:26 GMT</pubDate></item><item><title><![CDATA[Reply to Replace on Wed, 04 Jan 2006 10:37:47 GMT]]></title><description><![CDATA[<p>Könntet mir jmd evt Links zu Tutorials über das Thema geben. Soweit bin ich nun:</p>
<p>#include &lt;stdio.h&gt;</p>
<p>void main ( void )<br />
{</p>
<p>FILE *datei;</p>
<p>datei = fopen ( &quot;test.dat&quot; , &quot;r+&quot; );<br />
if (datei == NULL )<br />
{<br />
/*<br />
Da ist wohl ein Fehler aufgetreten! */</p>
<p>printf (&quot;\nDie Datei konnte nicht geöffnet werden!\n&quot;);<br />
}<br />
else<br />
{<br />
/*<br />
Hier soll der TXT (z.b. 1 wird zu 2) ersetzt werden */</p>
<p>fclose (datei);<br />
}</p>
<p>}</p>
]]></description><link>https://www.c-plusplus.net/forum/post/956408</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/956408</guid><dc:creator><![CDATA[cyberdevil87]]></dc:creator><pubDate>Wed, 04 Jan 2006 10:37:47 GMT</pubDate></item><item><title><![CDATA[Reply to Replace on Wed, 04 Jan 2006 12:33:18 GMT]]></title><description><![CDATA[<p>so gehts mit c++ :xmas1:</p>
<pre><code class="language-cpp">//DEV C++ 4.9.9.2
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;fstream&gt;

using namespace std;

string ersetzen(string s,string such,string ersetz) {
   int pos=0;
   while ((pos=s.find(such,pos))&lt;s.size()) {
      s.replace(pos,ersetz.size(),ersetz);
      pos++;
   }
   return s;
}

int main() {
   string s;

    ifstream fi(&quot;dat.txt&quot;);
    if (!fi) {
         cout&lt;&lt;&quot;datei nicht gefunden \n&quot;;
         system(&quot;pause&quot;);
         exit(1);
    }
    while (!fi.eof()) {
       getline(fi,s);
       cout&lt;&lt;&quot;gelesen &quot;&lt;&lt;s&lt;&lt;endl;
       s=ersetzen(s,&quot;1&quot;,&quot;2&quot;);
       cout&lt;&lt;&quot;ersetzt &quot;&lt;&lt;s&lt;&lt;endl;
    }
    system(&quot;Pause&quot;);
    return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/956528</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/956528</guid><dc:creator><![CDATA[kermit1]]></dc:creator><pubDate>Wed, 04 Jan 2006 12:33:18 GMT</pubDate></item></channel></rss>