<?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[An &amp;quot;Textmarke&amp;quot; in Textfile schreiben]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte gerne an eine bestimmte Position in einem Textfile einen Wert schreiben.<br />
In diesem Textfile sollen sich verschiedene Textmarken befinden hinter der dann der Wert geschrieben wird. Also z.B:</p>
<p>Textmarke_1= &quot;Wert1&quot;</p>
<p>Textmarke_2= &quot;Wert_2&quot; ....</p>
<p>Öffnen und schreiben kriege ich hin, nur entweder wird in die Datei geschrieben und gelöscht oder ans Ende der Datei geschrieben.<br />
Hat jemand eine Idee, wie ich Textmarken &quot;anspringen&quot; und dahinter schreiben kann?<br />
Kann man überhaupt in einem Textfile Textmarken erstellen oder muß nach Schlüsselwörtern wie &quot;Textmarke_1&quot; gesucht werden und danach wird geschrieben?<br />
Bin für jede Hilfe dankbar.</p>
<p>Gruß<br />
Mark</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/234268/an-quot-textmarke-quot-in-textfile-schreiben</link><generator>RSS for Node</generator><lastBuildDate>Thu, 24 Sep 2026 11:14:29 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/234268.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 15 Feb 2009 18:27:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to An &amp;quot;Textmarke&amp;quot; in Textfile schreiben on Sun, 15 Feb 2009 18:27:11 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte gerne an eine bestimmte Position in einem Textfile einen Wert schreiben.<br />
In diesem Textfile sollen sich verschiedene Textmarken befinden hinter der dann der Wert geschrieben wird. Also z.B:</p>
<p>Textmarke_1= &quot;Wert1&quot;</p>
<p>Textmarke_2= &quot;Wert_2&quot; ....</p>
<p>Öffnen und schreiben kriege ich hin, nur entweder wird in die Datei geschrieben und gelöscht oder ans Ende der Datei geschrieben.<br />
Hat jemand eine Idee, wie ich Textmarken &quot;anspringen&quot; und dahinter schreiben kann?<br />
Kann man überhaupt in einem Textfile Textmarken erstellen oder muß nach Schlüsselwörtern wie &quot;Textmarke_1&quot; gesucht werden und danach wird geschrieben?<br />
Bin für jede Hilfe dankbar.</p>
<p>Gruß<br />
Mark</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1664359</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1664359</guid><dc:creator><![CDATA[string]]></dc:creator><pubDate>Sun, 15 Feb 2009 18:27:11 GMT</pubDate></item><item><title><![CDATA[Reply to An &amp;quot;Textmarke&amp;quot; in Textfile schreiben on Sun, 15 Feb 2009 18:50:42 GMT]]></title><description><![CDATA[<p>Alles einlesen, suchen, ersetzen und dann wieder zurückschreiben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1664380</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1664380</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Sun, 15 Feb 2009 18:50:42 GMT</pubDate></item><item><title><![CDATA[Reply to An &amp;quot;Textmarke&amp;quot; in Textfile schreiben on Mon, 16 Feb 2009 16:20:20 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>danke für den Tipp. Dachte ich mir, dass das mit Textmarken nicht geht.<br />
Das Einlesen und Suchen habe ich hinbekommen. Ersetzt und zurückgeschrieben wird auch etwas, nur nicht so wie ich mir das vorstelle.<br />
Ich glaube beim Replace geht etwas schief.Ich poste mal den Code, vielleicht findet jemand den Fehler auf Anhieb.</p>
<pre><code class="language-cpp">FHandle = fopen (FName , &quot;r&quot;);
   pFile = fopen (&quot;c:\\myfile.txt&quot; , &quot;w&quot;); 
   if (FHandle == NULL) perror (&quot;Error opening file&quot;);
   else
   {
     while ( ! feof (FHandle) )
   {
       fgets (buffer , 100 , FHandle);
       if ((buffer[0]=='§') || (buffer[0]=='\r') || (buffer[0]=='\n'))
       {
           // dann mach nichts, weil bei § und leere Zeile halt nix gemacht werden soll
       }
       else if (strstr(buffer, &quot;wert1&quot;) == buffer)
       {
           a.Replace(&quot;wert1&quot;, &quot;xxxxxxxxxxxxxx&quot;);
           cout&lt;&lt;&quot;wert1 gefunden&quot;&lt;&lt;endl;
       }
       else if (strstr(buffer, &quot;wert2&quot;) == buffer)
       {
	   a.Replace(&quot;wert2&quot;, &quot;yyyyyyyyyyyyy&quot;);
           cout&lt;&lt;&quot;wert2 gefunden&quot;&lt;&lt;endl;
       }
       else if (strstr(buffer, &quot;wert3&quot;) == buffer)
       {
	   a.Replace(&quot;wert3&quot;, &quot;zzzzzzzzzzzz&quot;);
           cout&lt;&lt;&quot;wert3 gefunden&quot;&lt;&lt;endl;
       }
       fwrite (buffer , 1 , sizeof(buffer), pFile);
       //cout&lt;&lt;buffer&lt;&lt;endl;
     }
     fclose (FHandle);
   }
   return 0;
</code></pre>
<p>Es soll also aus einem Textfile gelesen werden, bestimmte &quot;werte&quot; ersetzt werden und dann soll das file wieder zurückgelesen oder wie hier in eine andere Datei gespeichert werden.<br />
Das &quot;cout&quot; habe ich nur zur Überprüfung eingebaut, ob der Wert gefunden wurde.</p>
<p>Gruß<br />
Mark</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1664784</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1664784</guid><dc:creator><![CDATA[string]]></dc:creator><pubDate>Mon, 16 Feb 2009 16:20:20 GMT</pubDate></item><item><title><![CDATA[Reply to An &amp;quot;Textmarke&amp;quot; in Textfile schreiben on Mon, 16 Feb 2009 16:24:41 GMT]]></title><description><![CDATA[<p>string schrieb:</p>
<blockquote>
<p>...</p>
</blockquote>
<p>Das gehört eher ins ANSI-C-Forum und nicht ins C++-Forum.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1664789</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1664789</guid><dc:creator><![CDATA[Tachyon]]></dc:creator><pubDate>Mon, 16 Feb 2009 16:24:41 GMT</pubDate></item><item><title><![CDATA[Reply to An &amp;quot;Textmarke&amp;quot; in Textfile schreiben on Mon, 16 Feb 2009 16:47:13 GMT]]></title><description><![CDATA[<p>Tachyon schrieb:</p>
<blockquote>
<p>string schrieb:</p>
<blockquote>
<p>...</p>
</blockquote>
<p>Das gehört eher ins ANSI-C-Forum und nicht ins C++-Forum.</p>
</blockquote>
<p>An sich richtig, nur werden die ihn wieder ins C++ Forum verweisen (cout), auch wenn der Code eigentlich fast reines C ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1664803</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1664803</guid><dc:creator><![CDATA[asc]]></dc:creator><pubDate>Mon, 16 Feb 2009 16:47:13 GMT</pubDate></item><item><title><![CDATA[Reply to An &amp;quot;Textmarke&amp;quot; in Textfile schreiben on Mon, 16 Feb 2009 17:58:16 GMT]]></title><description><![CDATA[<blockquote>
<p>Das gehört eher ins ANSI-C-Forum und nicht ins C++-Forum.</p>
</blockquote>
<p>Hallo,</p>
<p>also, ich kann da momentan schwehr zwischen C und C++ trennen, weil ich noch relativ neu am Thema bin. Ziel für mich ist eigentlich C++ und ich darfs kaum sagen sonst wird wieder mit Verschiebung gedroht - MFC.<br />
Mir wäre erstmal sehr damit geholfen wenn jemand ein Tipp für mein Problem hätte.</p>
<p>Gruß<br />
Mark</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1664858</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1664858</guid><dc:creator><![CDATA[string]]></dc:creator><pubDate>Mon, 16 Feb 2009 17:58:16 GMT</pubDate></item><item><title><![CDATA[Reply to An &amp;quot;Textmarke&amp;quot; in Textfile schreiben on Mon, 16 Feb 2009 18:28:36 GMT]]></title><description><![CDATA[<p>Vorschlag:<br />
Du holst dir jetzt ein wirkliches C++-Buch/Tutorial und probierst das ganze nochmal mit C++-Mitteln, die da wären std::ifstream / std::ofstream / std::string usw.</p>
<p>Container und Algorithmen findest du hier:<br />
<a href="http://www.cplusplus.com/reference/" rel="nofollow">http://www.cplusplus.com/reference/</a></p>
<p>Und dann helfen wir dir hier gerne. <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/1664880</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1664880</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Mon, 16 Feb 2009 18:28:36 GMT</pubDate></item><item><title><![CDATA[Reply to An &amp;quot;Textmarke&amp;quot; in Textfile schreiben on Mon, 16 Feb 2009 19:07:23 GMT]]></title><description><![CDATA[<blockquote>
<p>Vorschlag:<br />
Du holst dir jetzt ein wirkliches C++-Buch/Tutorial und probierst das ganze nochmal mit C++-Mitteln, die da wären std::ifstream / std::ofstream / std::string usw.</p>
</blockquote>
<p>Vielen Dank für Deinen guten Vorschlag, dass hilft mir viel weiter!</p>
<p>Nochmals Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1664897</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1664897</guid><dc:creator><![CDATA[string]]></dc:creator><pubDate>Mon, 16 Feb 2009 19:07:23 GMT</pubDate></item></channel></rss>