<?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[Exakte (binäre) Deteikopie erstellen]]></title><description><![CDATA[<p>Hallo!</p>
<p>Ich versuche grade, eine einfach Funktion zu schreiben, die mir eine (exakte) kopie einer Datei erstellt. Per fstream kann ich die dateien ja im binärmodus öffnen und dann byteweise kopieren. Nur stimmt die kopie nicht mit dem original zusammen *confused*</p>
<p>Der code (ausschnitt) ist hier:</p>
<pre><code class="language-cpp">std::fstream fs;
    fs.open(&quot;test.jpg&quot;, std::fstream::binary | std::fstream::in);

    std::fstream fs2;
    fs2.open(&quot;out.jpg&quot;, std::fstream::binary | std::fstream::out);

    char c;

    while (fs.good())
    {
        fs &gt;&gt; c;

        fs2 &lt;&lt; c;        
    }

    fs.close();
    fs2.close();
</code></pre>
<p>Ideen wären fett!</p>
<p>Grüße<br />
Pino</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/262986/exakte-binäre-deteikopie-erstellen</link><generator>RSS for Node</generator><lastBuildDate>Sun, 06 Sep 2026 05:55:09 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/262986.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 14 Mar 2010 14:19:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Exakte (binäre) Deteikopie erstellen on Sun, 14 Mar 2010 14:19:58 GMT]]></title><description><![CDATA[<p>Hallo!</p>
<p>Ich versuche grade, eine einfach Funktion zu schreiben, die mir eine (exakte) kopie einer Datei erstellt. Per fstream kann ich die dateien ja im binärmodus öffnen und dann byteweise kopieren. Nur stimmt die kopie nicht mit dem original zusammen *confused*</p>
<p>Der code (ausschnitt) ist hier:</p>
<pre><code class="language-cpp">std::fstream fs;
    fs.open(&quot;test.jpg&quot;, std::fstream::binary | std::fstream::in);

    std::fstream fs2;
    fs2.open(&quot;out.jpg&quot;, std::fstream::binary | std::fstream::out);

    char c;

    while (fs.good())
    {
        fs &gt;&gt; c;

        fs2 &lt;&lt; c;        
    }

    fs.close();
    fs2.close();
</code></pre>
<p>Ideen wären fett!</p>
<p>Grüße<br />
Pino</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1868770</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1868770</guid><dc:creator><![CDATA[ANGs_Pino]]></dc:creator><pubDate>Sun, 14 Mar 2010 14:19:58 GMT</pubDate></item><item><title><![CDATA[Reply to Exakte (binäre) Deteikopie erstellen on Sun, 14 Mar 2010 14:28:13 GMT]]></title><description><![CDATA[<p>fstream hat keinen Überladenen &gt;&gt; bzw. &lt;&lt; operator für char.</p>
<p>Nimm einen anderen Datentyp oder mach es so:</p>
<pre><code class="language-cpp">std::fstream fs;
    fs.open(&quot;test.jpg&quot;, std::fstream::binary | std::fstream::in);

    std::fstream fs2;
    fs2.open(&quot;out.jpg&quot;, std::fstream::binary | std::fstream::out);

    char c;

    while (fs.good())
    {
        c = fs.get(); // hier

        fs2.put(c);   // und hier
    }

    fs.close();
    fs2.close();
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1868778</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1868778</guid><dc:creator><![CDATA[blub* 0]]></dc:creator><pubDate>Sun, 14 Mar 2010 14:28:13 GMT</pubDate></item><item><title><![CDATA[Reply to Exakte (binäre) Deteikopie erstellen on Sun, 14 Mar 2010 14:34:40 GMT]]></title><description><![CDATA[<p>Einfacher:</p>
<pre><code class="language-cpp">fs2 &lt;&lt; fs.rdbuf();
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1868783</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1868783</guid><dc:creator><![CDATA[seldon]]></dc:creator><pubDate>Sun, 14 Mar 2010 14:34:40 GMT</pubDate></item><item><title><![CDATA[Reply to Exakte (binäre) Deteikopie erstellen on Sun, 14 Mar 2010 14:44:04 GMT]]></title><description><![CDATA[<p>blub² schrieb:</p>
<blockquote>
<p>fstream hat keinen Überladenen &gt;&gt; bzw. &lt;&lt; operator für char.</p>
</blockquote>
<p>Unsinn!</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/10001">@ANGs_Pino</a>,<br />
Das Problem ist, dass bei den Operator &gt;&gt; und &lt;&lt; eine Formatierung durchgeführt wird. Sowas ist eher ungewollt, wenn man eine genaue 1:1 Kopie haben möchte. Entweder verwendest du die Lösung, welche seldon aufgezeigt hat, oder du arbeitest über einen Puffer:</p>
<pre><code class="language-cpp">std::ifstream in(&quot;test.jpg&quot;, std::ios::binary);
std::ofstream out(&quot;out.jpg&quot;, std::ios::binary);

char buffer[4096];

while(in.read(buffer, 4096))
{
  out.write(buffer, in.gcount());
}

out.write(buffer, in.gcount());
</code></pre>
<p>Grüssli</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1868791</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1868791</guid><dc:creator><![CDATA[Dravere]]></dc:creator><pubDate>Sun, 14 Mar 2010 14:44:04 GMT</pubDate></item><item><title><![CDATA[Reply to Exakte (binäre) Deteikopie erstellen on Sun, 14 Mar 2010 14:47:46 GMT]]></title><description><![CDATA[<p>Dravere schrieb:</p>
<blockquote>
<p>blub² schrieb:</p>
<blockquote>
<p>fstream hat keinen Überladenen &gt;&gt; bzw. &lt;&lt; operator für char.</p>
</blockquote>
<p>Unsinn!</p>
</blockquote>
<p>Argh, stimmt du hast Recht!<br />
Hab ich übersehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1868792</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1868792</guid><dc:creator><![CDATA[blub* 0]]></dc:creator><pubDate>Sun, 14 Mar 2010 14:47:46 GMT</pubDate></item></channel></rss>