<?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[datei kopieren]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;windows.h&gt;
#include &lt;fstream&gt;
using namespace std;

int main()
{
    ifstream a(&quot;orginal.mp3&quot;, ios_base::binary);
    ofstream b(&quot;kopie.mp3&quot;, ios_base::binary);

    if (a)
    {
        if (b)
        {
        a.seekg(0L, ios_base::end);
        unsigned long size = a.tellg();
        char *byte = new char[size];
        a&gt;&gt;byte;
        delete[] byte;
        byte = NULL;
        }
    }
}
</code></pre>
<p>ich möchte nun den inhalt von byte in eine datei schreiben, kriege aber mit diesem hier: byte&gt;&gt;b; einen fehler</p>
<p>nur für die, die denken es gibt ja rdbuf.. ich kenne es, bin aber neugierig</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/148614/datei-kopieren</link><generator>RSS for Node</generator><lastBuildDate>Sat, 05 Sep 2026 00:41:42 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/148614.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 28 May 2006 17:33:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to datei kopieren on Sun, 28 May 2006 17:33:59 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;windows.h&gt;
#include &lt;fstream&gt;
using namespace std;

int main()
{
    ifstream a(&quot;orginal.mp3&quot;, ios_base::binary);
    ofstream b(&quot;kopie.mp3&quot;, ios_base::binary);

    if (a)
    {
        if (b)
        {
        a.seekg(0L, ios_base::end);
        unsigned long size = a.tellg();
        char *byte = new char[size];
        a&gt;&gt;byte;
        delete[] byte;
        byte = NULL;
        }
    }
}
</code></pre>
<p>ich möchte nun den inhalt von byte in eine datei schreiben, kriege aber mit diesem hier: byte&gt;&gt;b; einen fehler</p>
<p>nur für die, die denken es gibt ja rdbuf.. ich kenne es, bin aber neugierig</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1066860</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1066860</guid><dc:creator><![CDATA[mark&#96;ler]]></dc:creator><pubDate>Sun, 28 May 2006 17:33:59 GMT</pubDate></item><item><title><![CDATA[Reply to datei kopieren on Sun, 28 May 2006 17:41:17 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>wo rufst du die Ausgabeoperation b&lt;&lt;byte denn auf? Den Auruf solltest du vor delete [] byte packen <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>
<p>MfG</p>
<p>GPC</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1066871</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1066871</guid><dc:creator><![CDATA[GPC]]></dc:creator><pubDate>Sun, 28 May 2006 17:41:17 GMT</pubDate></item><item><title><![CDATA[Reply to datei kopieren on Sun, 28 May 2006 17:54:58 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">char *byte = new char[size];
        a&gt;&gt;byte;
        byte&gt;&gt;b;
        delete[] byte;
</code></pre>
<p>|<br />
|<br />
|<br />
(wie geht eigentlich ein pfeil nach unten?)</p>
<p>no match for operator &gt;&gt; in byte&gt;&gt;b</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1066884</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1066884</guid><dc:creator><![CDATA[mark&#96;ler]]></dc:creator><pubDate>Sun, 28 May 2006 17:54:58 GMT</pubDate></item><item><title><![CDATA[Reply to datei kopieren on Sun, 28 May 2006 18:38:19 GMT]]></title><description><![CDATA[<p>char* definiert keinen &gt;&gt; operator, du musst also b &lt;&lt; byte schreiben. Trotzdem funktioniert deine Idee so nicht, da erstens wieder an den Anfang der Datei gehen muss, und der &gt;&gt; operator auch gar nicht weiß, wieviel Bytes erlesen, bzw. schreiben soll. Dazu gibt es die FUnktionen read und write:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;fstream&gt;

int main() {
    std::ifstream a(&quot;original.mp3&quot;, std::ios::binary);
    std::ofstream b(&quot;kopie.mp3&quot;, std::ios::binary);

    if(a &amp;&amp; b) {
        char buf[256];
        do {
            a.read(buf, sizeof(buf));
            b.write(buf, a.gcount());
        } while(a);
    }
    else {
        std::cout &lt;&lt; &quot;Datei nicht gefunden!&quot;;
    }
}
</code></pre>
<p>Diese Möglichkeit verbraucht außerdem auch weniger RAM. (Kann aber sein dass sie langsamer ist)</p>
<p>mfg.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1066918</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1066918</guid><dc:creator><![CDATA[joomoo]]></dc:creator><pubDate>Sun, 28 May 2006 18:38:19 GMT</pubDate></item><item><title><![CDATA[Reply to datei kopieren on Sun, 28 May 2006 18:47:05 GMT]]></title><description><![CDATA[<p>warum muss ich an den anfang der datei gehen? ich habe doch den buffer da.?</p>
<p>wenn ich den inhalt von dem buffer in die datei schreibe muss in den inhalt nicht kennen oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1066925</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1066925</guid><dc:creator><![CDATA[mark&#96;ler]]></dc:creator><pubDate>Sun, 28 May 2006 18:47:05 GMT</pubDate></item><item><title><![CDATA[Reply to datei kopieren on Sun, 28 May 2006 18:47:17 GMT]]></title><description><![CDATA[<p>Ich hab's mal getestet, sie ist wirklich langsam:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;boost/filesystem/operations.hpp&gt;
#include &lt;ctime&gt;

int main() {
    std::ifstream a(&quot;original.wmv&quot;, std::ios::binary);
    std::ofstream b(&quot;kopie.wmv&quot;, std::ios::binary);

    if(a &amp;&amp; b) {
        time_t start = time(0);
        char buf[256];
        do {
            a.read(buf, sizeof(buf));
            b.write(buf, a.gcount());
        } while(a);
        std::cout &lt;&lt; &quot;Zeit: &quot; &lt;&lt; time(0) - start &lt;&lt; &quot; Sekunden&quot; &lt;&lt; std::endl;
        start = time(0);
        boost::filesystem::copy_file(&quot;original.wmv&quot;, &quot;kopie2.wmv&quot;);
        std::cout &lt;&lt; &quot;Zeit: &quot; &lt;&lt; time(0) - start &lt;&lt; &quot; Sekunden&quot; &lt;&lt; std::endl;
    }
    else {
        std::cout &lt;&lt; &quot;Datei nicht gefunden!&quot;;
    }
}
</code></pre>
<p>Ausgabe:</p>
<pre><code>Zeit: 26 Sekunden
Zeit: 8 Sekunden
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1066926</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1066926</guid><dc:creator><![CDATA[joomoo]]></dc:creator><pubDate>Sun, 28 May 2006 18:47:17 GMT</pubDate></item><item><title><![CDATA[Reply to datei kopieren on Sun, 28 May 2006 18:48:41 GMT]]></title><description><![CDATA[<p>mark`ler schrieb:</p>
<blockquote>
<p>warum muss ich an den anfang der datei gehen? ich habe doch den buffer da.?</p>
</blockquote>
<p>Da du mit seekg an das Ende gesprungen bist.</p>
<blockquote>
<p>wenn ich den inhalt von dem buffer in die datei schreibe muss in den inhalt nicht kennen oder?</p>
</blockquote>
<p>Ne wieso?</p>
<p>mfg.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1066927</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1066927</guid><dc:creator><![CDATA[joomoo]]></dc:creator><pubDate>Sun, 28 May 2006 18:48:41 GMT</pubDate></item><item><title><![CDATA[Reply to datei kopieren on Sun, 28 May 2006 18:50:01 GMT]]></title><description><![CDATA[<p>schon erledigt. habe einen schritt nicht berücksichtigt. habe ja noch nichts in den buffer geschrieben <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>meine dummheit</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1066929</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1066929</guid><dc:creator><![CDATA[mark&#96;ler]]></dc:creator><pubDate>Sun, 28 May 2006 18:50:01 GMT</pubDate></item><item><title><![CDATA[Reply to datei kopieren on Sun, 28 May 2006 18:57:53 GMT]]></title><description><![CDATA[<p>So ist man sogar nen bisschen schneller als boost:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;boost/filesystem/operations.hpp&gt;
#include &lt;ctime&gt;

int main() {
    std::ifstream a(&quot;original.wmv&quot;, std::ios::binary);
    std::ofstream b(&quot;kopie.wmv&quot;, std::ios::binary);

    if(a &amp;&amp; b) {
        time_t start = time(0);
        a.seekg(0, std::ios::end);
        std::streamsize size = a.tellg();
        char* buf = new char[size];
        a.seekg(0);
        do {
            a.read(buf, size);
            b.write(buf, a.gcount());
        } while(a);
        delete[] buf;
        std::cout &lt;&lt; &quot;Zeit: &quot; &lt;&lt; time(0) - start &lt;&lt; &quot; Sekunden&quot; &lt;&lt; std::endl;
        start = time(0);
        boost::filesystem::copy_file(&quot;original.wmv&quot;, &quot;kopie2.wmv&quot;);
        std::cout &lt;&lt; &quot;Zeit: &quot; &lt;&lt; time(0) - start &lt;&lt; &quot; Sekunden&quot; &lt;&lt; std::endl;
    }
    else {
        std::cout &lt;&lt; &quot;Datei nicht gefunden!&quot;;
    }
}
</code></pre>
<p>Man muss halt nur den richtigen Mix aus RAM-Verbrauch und Geschwindigkeit finden.</p>
<p>mfg.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1066937</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1066937</guid><dc:creator><![CDATA[joomoo]]></dc:creator><pubDate>Sun, 28 May 2006 18:57:53 GMT</pubDate></item><item><title><![CDATA[Reply to datei kopieren on Sun, 28 May 2006 19:12:50 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;fstream&gt;
using namespace std;

int main()
{
   ifstream ein(&quot;original.wmv&quot;);
   ofstream aus(&quot;kopie.wmv&quot;);
   aus &lt;&lt; ein.rdbuf();
   return 0;
}
</code></pre>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1066942</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1066942</guid><dc:creator><![CDATA[Helmut S.]]></dc:creator><pubDate>Sun, 28 May 2006 19:12:50 GMT</pubDate></item></channel></rss>