<?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[Text in Textfile einfügen]]></title><description><![CDATA[<p>Hi to all</p>
<p>VS6.0 MFC<br />
Problemstellung:</p>
<p>CStdioFile fileo;<br />
fileo.ReadString(strOutput);<br />
strOutput = strOutput + &quot;Rolf \t&quot;;<br />
fileo.WriteString(strOutput);<br />
fileo.Close();<br />
--&gt; ich lese einen String aus einer Textdatei z.B. &quot;Hallo \t&quot;<br />
--&gt; strOutput = &quot;Hallo \t Rolf \t&quot;<br />
--&gt; strOutput in Textdatei wieder einfügen.</p>
<p>Was passiert:<br />
1. gar nichts. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /><br />
Es wird nichts geschrieben.<br />
Würde ich &lt;fileo.ReadString(strOutput);&gt; weglassen und strOutput direkt zuweisen, würde mir in der Textdatei alles überschrieben!</p>
<p>Wie soll es aussehen:<br />
Textdatei:<br />
&quot;Hallo 'TAB'&quot; &lt;-- Zeile 1<br />
&quot;Wie geht es 'TAB'&quot; &lt;-- Zeile 2</p>
<p>jetzt kommt mein Code....</p>
<p>jetzt steht in der Textdatei:<br />
&quot;Hallo 'TAB' Rolf 'TAB' &lt;-- Zeile 1<br />
&quot;Wie geht es 'TAB'&quot; &lt;-- Zeile 2</p>
<p>Für Hilfe und Anregungen danke ich schon jetzt mal!<br />
Es grüsst<br />
Rolf</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/162617/text-in-textfile-einfügen</link><generator>RSS for Node</generator><lastBuildDate>Thu, 30 Jul 2026 03:39:50 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/162617.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 20 Oct 2006 13:37:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Text in Textfile einfügen on Fri, 20 Oct 2006 13:37:03 GMT]]></title><description><![CDATA[<p>Hi to all</p>
<p>VS6.0 MFC<br />
Problemstellung:</p>
<p>CStdioFile fileo;<br />
fileo.ReadString(strOutput);<br />
strOutput = strOutput + &quot;Rolf \t&quot;;<br />
fileo.WriteString(strOutput);<br />
fileo.Close();<br />
--&gt; ich lese einen String aus einer Textdatei z.B. &quot;Hallo \t&quot;<br />
--&gt; strOutput = &quot;Hallo \t Rolf \t&quot;<br />
--&gt; strOutput in Textdatei wieder einfügen.</p>
<p>Was passiert:<br />
1. gar nichts. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /><br />
Es wird nichts geschrieben.<br />
Würde ich &lt;fileo.ReadString(strOutput);&gt; weglassen und strOutput direkt zuweisen, würde mir in der Textdatei alles überschrieben!</p>
<p>Wie soll es aussehen:<br />
Textdatei:<br />
&quot;Hallo 'TAB'&quot; &lt;-- Zeile 1<br />
&quot;Wie geht es 'TAB'&quot; &lt;-- Zeile 2</p>
<p>jetzt kommt mein Code....</p>
<p>jetzt steht in der Textdatei:<br />
&quot;Hallo 'TAB' Rolf 'TAB' &lt;-- Zeile 1<br />
&quot;Wie geht es 'TAB'&quot; &lt;-- Zeile 2</p>
<p>Für Hilfe und Anregungen danke ich schon jetzt mal!<br />
Es grüsst<br />
Rolf</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1158387</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1158387</guid><dc:creator><![CDATA[Rolf_VIII]]></dc:creator><pubDate>Fri, 20 Oct 2006 13:37:03 GMT</pubDate></item><item><title><![CDATA[Reply to Text in Textfile einfügen on Fri, 20 Oct 2006 13:53:38 GMT]]></title><description><![CDATA[<p>wie waere es mit:</p>
<pre><code class="language-cpp">CStdioFile file;
file.Open(FileString, CFile::modeReadWrite);
</code></pre>
<p>amsonsten wuerde ich fstream bevorzugen {da kann man auch mit CStrings arbeiten}</p>
<p>zb:</p>
<pre><code class="language-cpp">std::ofstream file(csFile, std::ios::out|std::ios::app);
file.write(csString, csString.GetLength());
file.close();
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1158408</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1158408</guid><dc:creator><![CDATA[EXDW]]></dc:creator><pubDate>Fri, 20 Oct 2006 13:53:38 GMT</pubDate></item><item><title><![CDATA[Reply to Text in Textfile einfügen on Fri, 20 Oct 2006 14:16:20 GMT]]></title><description><![CDATA[<p>ach sorry habe ich natürlich gemacht:</p>
<p>CStdioFile fileo;<br />
fileo.Open(TEXT(&quot;C:\\MyDoc\\Textdatei.txt&quot;), CFile::modeReadWrite|CFile::shareExclusive|CFile::typeBinary, &amp;fileException))<br />
...<br />
...<br />
CString strOutput(&quot;&quot;);<br />
fileo.ReadString(strOutput);<br />
strOutput = strOutput + &quot;Rolf \t&quot;;<br />
fileo.WriteString(strOutput);<br />
fileo.Close();</p>
<p>wie gesagt, das Problem ist trotzdem da!<br />
--------<br />
weiter habe ich jetzt versucht:</p>
<p>CString csFile = TEXT(&quot;C:\\MyDoc\\Textdatei.txt&quot;);<br />
CString csString = &quot;AAA&quot;;<br />
std::ofstream file(csFile, std::ios::out|std::ios::app);<br />
file.write(csString, csString.GetLength());<br />
file.close();</p>
<p>aber selbes Problem <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /> -&gt; es passiert gar nichts.<br />
Es wird nichts geschrieben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1158425</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1158425</guid><dc:creator><![CDATA[Rolf_VIII]]></dc:creator><pubDate>Fri, 20 Oct 2006 14:16:20 GMT</pubDate></item><item><title><![CDATA[Reply to Text in Textfile einfügen on Fri, 20 Oct 2006 14:19:01 GMT]]></title><description><![CDATA[<p>Mr Evil schrieb:</p>
<blockquote>
<p>wie waere es mit:</p>
<pre><code class="language-cpp">CStdioFile file;
file.Open(FileString, CFile::modeReadWrite);
</code></pre>
<p>amsonsten wuerde ich fstream bevorzugen {da kann man auch mit CStrings arbeiten}</p>
</blockquote>
<p>Und wieso sollte man bei CStdioFile nicht mit CStrings arbeiten können? Ich meine CString ist von der MFC und CStdioFile auch, da liegt es ja nahe, dass man CStrings brauchen kann, nicht? ^^</p>
<p>@Rolf<br />
Desweitern kann man nicht einfach so auf eine Zeile zugreifen. Also wenn du ReadString machst, dann liest es eine Zeile weiter. Beim nächsten ReadString oder WriteString ist er auf er nächsten Zeile. Daher musst du entweder alles auslesen, die entsprechenden Zeilen verändern und die Datei leeren und wieder alles hineinschreiben. Oder du probierst etwas mit den CFile Seek Funktionen. Ich weiss leider nicht ob es geht, aber vielleicht könnte es mit einem SeekToBegin gehen. Also auslesen, manipulieren, seektobegin und danach hineinschreiben. Musst halt ein wenig ausprobieren.</p>
<p>Edit: Hab gerade noch ein wenig getestet. Ok mit dem Seek geht es nicht, war eigentlich zu erwarten. Daher musst du wohl zuerst alles auslesen Datei, wieder schliessen, dann manipulieren, wieder öffnen mit CFile::modeCreate | CFile::modeWrite und dann wieder alles hineinschreiben.</p>
<p>Vielleicht hat aber jemand noch eine besser Lösung auf Lager.</p>
<p>Grüssli</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1158429</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1158429</guid><dc:creator><![CDATA[Dravere]]></dc:creator><pubDate>Fri, 20 Oct 2006 14:19:01 GMT</pubDate></item><item><title><![CDATA[Reply to Text in Textfile einfügen on Fri, 20 Oct 2006 14:24:58 GMT]]></title><description><![CDATA[<p>Dravere schrieb:</p>
<blockquote>
<p>Mr Evil schrieb:</p>
<blockquote>
<p>wie waere es mit:</p>
<pre><code class="language-cpp">CStdioFile file;
file.Open(FileString, CFile::modeReadWrite);
</code></pre>
<p>amsonsten wuerde ich fstream bevorzugen {da kann man auch mit CStrings arbeiten}</p>
</blockquote>
<p>Und wieso sollte man bei CStdioFile nicht mit CStrings arbeiten können?</p>
</blockquote>
<p>ich hab nicht gesagt das man das mit CStdioFile nicht kann - ich sagte <strong>auch</strong></p>
<p>da kann man auch mit CStrings arbeiten += wie bei CStdioFile &amp;&amp; CFile</p>
<p>#gg</p>
<p>//dazuedit</p>
<p>wie waer es mit append - haengt er immer an eine neue zeile an ? wenn kein \n ist muesste es nach meinem denken angehangen werden</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1158435</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1158435</guid><dc:creator><![CDATA[EXDW]]></dc:creator><pubDate>Fri, 20 Oct 2006 14:24:58 GMT</pubDate></item><item><title><![CDATA[Reply to Text in Textfile einfügen on Fri, 20 Oct 2006 14:24:44 GMT]]></title><description><![CDATA[<p>Hi Dravere</p>
<p>wenn ich mich nicht verguckt habe, habe ich Deinen Vorschlag auch schon ausprobiert.<br />
-Zitat: ALLES lesen, ändern, schreiben. ok. aber was wenn die Datei in Zukunft mal riesengross ist? (5,10,20MB)</p>
<p>-Meine Frage:<br />
Wenn ich eine Textdatei mit einem Editor öffne, kann ich ja auch irgendwo neuen Text einfügen, ohne dass das bestehende überschrieben wird. (ausser Insert-Taste on) und die Zeile wird einfach etwas länger. Das wäre mein Wunsch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1158436</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1158436</guid><dc:creator><![CDATA[Rolf_VIII]]></dc:creator><pubDate>Fri, 20 Oct 2006 14:24:44 GMT</pubDate></item><item><title><![CDATA[Reply to Text in Textfile einfügen on Fri, 20 Oct 2006 14:50:35 GMT]]></title><description><![CDATA[<p>habe mal folgendes probiert:</p>
<p>Textdatei-Inhalt:<br />
111 TAB<br />
222 TAB<br />
333 TAB</p>
<p>Programmcode:<br />
...<br />
...<br />
fileo.ReadString(strOutput)&lt;=0;<br />
strOutput = strOutput + &quot;AAA&quot;;<br />
fileo.Close();</p>
<p>fileo.Open(TEXT(&quot;C:\\MyDoc\\Textdatei.txt&quot;), CFile::modeReadWrite|CFile::shareExclusive|CFile::typeBinary, &amp;fileException);<br />
fileo.WriteString(strOutput);<br />
fileo.Close();</p>
<p>1. Das Schreiben hat zwar jetzt funktioniert, warum auch immer (Read, ändern und gleich wieder write macht wohl Probleme)<br />
2. Textdatei-Inhalt jetzt:<br />
111 TAB AAA2 TAB<br />
333 TAB</p>
<p>wollte aber:<br />
111 TAB AAA<br />
222 TAB<br />
333 TAB</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1158447</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1158447</guid><dc:creator><![CDATA[Rolf_VIII]]></dc:creator><pubDate>Fri, 20 Oct 2006 14:50:35 GMT</pubDate></item><item><title><![CDATA[Reply to Text in Textfile einfügen on Fri, 20 Oct 2006 15:58:02 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">fileo.ReadString(strOutput)&lt;=0;
strOutput = strOutput + &quot;AAA\n&quot;;
fileo.Close();
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1158452</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1158452</guid><dc:creator><![CDATA[EXDW]]></dc:creator><pubDate>Fri, 20 Oct 2006 15:58:02 GMT</pubDate></item><item><title><![CDATA[Reply to Text in Textfile einfügen on Mon, 23 Oct 2006 10:46:33 GMT]]></title><description><![CDATA[<p>Hi Mr Evil</p>
<p>wird anschliessend strOutput wieder in das File geschrieben<br />
mit<br />
fileo.Open(TEXT(&quot;C:\\MyDoc\\Textdatei.txt&quot;), CFile::modeReadWrite|CFile::shareExclusive|CFile::typeBinary, &amp;fileException);<br />
fileo.WriteString(strOutput);<br />
fileo.Close();</p>
<p>steht in der ersten Zeile zwar &lt;111 TAB AAA&gt; jedoch in der zweiten Zeile wurde die '222' gelöscht.</p>
<p>Es muss wohl sein, ganzes File einlesen str.input ganzes File schreiben.<br />
(neben bei, was ich oben geschrieben habe betreffend einem Texteditierprogramm:<br />
dieses list ja auch das ganze File ein bevor ich es mutieren kann!)</p>
<p>Thanks to all<br />
Rolf</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1159409</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1159409</guid><dc:creator><![CDATA[Rolf_VIII]]></dc:creator><pubDate>Mon, 23 Oct 2006 10:46:33 GMT</pubDate></item></channel></rss>