<?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[fstream und seekp]]></title><description><![CDATA[<p>Hi</p>
<p>ich möchte gerne den Inhalt einer Datei überschreiben.<br />
Dazu habe ich folgenden Code geschrieben:</p>
<pre><code class="language-cpp">fstream datei;
  fstream out;
  AnsiString tmp = &quot;&quot;;
  bool start = true;
  char wert;

  datei.open(&quot;d:\\cpp\\Datei1.exe&quot;,ios::in | ios::binary);
  out.open(&quot;d:\\cpp\\Datei2.exe&quot;,ios::out | ios::binary);
  out.seekp(570048);
  /*if(datei.is_open())
  {
    while(!datei.eof())
    {
      wert = datei.get();
      if(!datei.eof())
      {
        out &lt;&lt; wert;
      }

    }
  }*/
  out &lt;&lt; &quot;Test&quot;;
  datei.close();
  out.close();
</code></pre>
<p>danach ist aber bei Datei2 (der in die ich schreibe) alles vor Byte 570048 mit '\0' beschrieben. Und der alte Inhalt ist weg. Was mache ich da falsch?</p>
<p>THX</p>
<p>Dagsta</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/168023/fstream-und-seekp</link><generator>RSS for Node</generator><lastBuildDate>Wed, 16 Sep 2026 05:57:46 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/168023.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 17 Dec 2006 17:33:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to fstream und seekp on Sun, 17 Dec 2006 17:33:11 GMT]]></title><description><![CDATA[<p>Hi</p>
<p>ich möchte gerne den Inhalt einer Datei überschreiben.<br />
Dazu habe ich folgenden Code geschrieben:</p>
<pre><code class="language-cpp">fstream datei;
  fstream out;
  AnsiString tmp = &quot;&quot;;
  bool start = true;
  char wert;

  datei.open(&quot;d:\\cpp\\Datei1.exe&quot;,ios::in | ios::binary);
  out.open(&quot;d:\\cpp\\Datei2.exe&quot;,ios::out | ios::binary);
  out.seekp(570048);
  /*if(datei.is_open())
  {
    while(!datei.eof())
    {
      wert = datei.get();
      if(!datei.eof())
      {
        out &lt;&lt; wert;
      }

    }
  }*/
  out &lt;&lt; &quot;Test&quot;;
  datei.close();
  out.close();
</code></pre>
<p>danach ist aber bei Datei2 (der in die ich schreibe) alles vor Byte 570048 mit '\0' beschrieben. Und der alte Inhalt ist weg. Was mache ich da falsch?</p>
<p>THX</p>
<p>Dagsta</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1193585</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1193585</guid><dc:creator><![CDATA[dagsta]]></dc:creator><pubDate>Sun, 17 Dec 2006 17:33:11 GMT</pubDate></item><item><title><![CDATA[Reply to fstream und seekp on Sun, 17 Dec 2006 18:02:37 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Das Flag ios::out kürzt die Datei automatisch auf die Länge von 0 Byte (d.h. löscht deren Inhalt), sofern du es nicht mit ios::in, ios::ate oder ios::app kombinierst.</p>
<p>Gruß, Caipi.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1193601</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1193601</guid><dc:creator><![CDATA[Caipi]]></dc:creator><pubDate>Sun, 17 Dec 2006 18:02:37 GMT</pubDate></item></channel></rss>