<?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 in 512Byte Blöcken kopieren?]]></title><description><![CDATA[<pre><code class="language-cpp">void DateiKopieren(string&amp; inf, string&amp; outf)
{
	unsigned char  buffer[512];
	int f;
   fstream infile, outfile;
	infile.open(inf.c_str(), ios::in | ios::binary);
   outfile.open(outf.c_str(),ios::out | ios:: binary);
   while(infile.read((char*)&amp;f, sizeof(*buffer)))
		outfile.write((char*)&amp;f, sizeof(*buffer));
   infile.close();
   outfile.close();

}
</code></pre>
<p>Hallo habe eine Frage zum Quelltext oben.<br />
Als Übung soll ein kleines programm geschrieben werden, dass eine beliebige Datei in 512Byte Häppchen kopieren soll. Das funktioniert soweit, bloß wie überprüft man so etwas? Wird jetzt die angegebene Datei in 512 Byte Blöcken kopiert??? Oder wie kann man es anders gestallten?<br />
MfG<br />
Dima</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/204916/datei-in-512byte-blöcken-kopieren</link><generator>RSS for Node</generator><lastBuildDate>Thu, 08 Oct 2026 19:43:36 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/204916.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 08 Feb 2008 09:41:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Datei in 512Byte Blöcken kopieren? on Fri, 08 Feb 2008 09:41:33 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">void DateiKopieren(string&amp; inf, string&amp; outf)
{
	unsigned char  buffer[512];
	int f;
   fstream infile, outfile;
	infile.open(inf.c_str(), ios::in | ios::binary);
   outfile.open(outf.c_str(),ios::out | ios:: binary);
   while(infile.read((char*)&amp;f, sizeof(*buffer)))
		outfile.write((char*)&amp;f, sizeof(*buffer));
   infile.close();
   outfile.close();

}
</code></pre>
<p>Hallo habe eine Frage zum Quelltext oben.<br />
Als Übung soll ein kleines programm geschrieben werden, dass eine beliebige Datei in 512Byte Häppchen kopieren soll. Das funktioniert soweit, bloß wie überprüft man so etwas? Wird jetzt die angegebene Datei in 512 Byte Blöcken kopiert??? Oder wie kann man es anders gestallten?<br />
MfG<br />
Dima</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1451769</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1451769</guid><dc:creator><![CDATA[Dima]]></dc:creator><pubDate>Fri, 08 Feb 2008 09:41:33 GMT</pubDate></item><item><title><![CDATA[Reply to Datei in 512Byte Blöcken kopieren? on Fri, 08 Feb 2008 09:46:16 GMT]]></title><description><![CDATA[<p>Pack eine Pause zwischen Lesen und Schreiben und schau dann nach. Entweder innerhalb des Programms andhand der Dateigröße oder eben außerhalb. outfile.flush() wäre wohl noch sinnvoll.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1451773</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1451773</guid><dc:creator><![CDATA[Fellhuhn]]></dc:creator><pubDate>Fri, 08 Feb 2008 09:46:16 GMT</pubDate></item><item><title><![CDATA[Reply to Datei in 512Byte Blöcken kopieren? on Fri, 08 Feb 2008 10:47:31 GMT]]></title><description><![CDATA[<p>Fellhuhn schrieb:</p>
<blockquote>
<p>Pack eine Pause zwischen Lesen und Schreiben und schau dann nach. Entweder innerhalb des Programms andhand der Dateigröße oder eben außerhalb. outfile.flush() wäre wohl noch sinnvoll.</p>
</blockquote>
<p>Hallo,<br />
1. wann ist der Einsatz von flush() sinnvoll? Denn in dem oberen Bsp. funtioniert es auch ohne. Oder kann es zu fehlern kommen?<br />
2. Beim einfügen von Pause in der schleife zwischen lesen und schreiben kopiert er mir nur das letzte zeichen einer txt-Datei.<br />
3. Wenn man für eine Variable 512Byte Speicher reserviert hat und kopiert den Inhalt einer Datei hinein, dann müsste ja die Ausgabedatei ein vielfaches von den 512Byte sein oder??? D.h. wenn ich eine datei kleiner 512Byte kopier dann müsste die ausgangsdatei ja 512Byte haben. Oder nicht???<br />
Denn im Oberen Bsp. ist es nicht der Fall Eingabedateigröße=Ausgabedateigröße.</p>
<p>MfG<br />
dima</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1451818</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1451818</guid><dc:creator><![CDATA[Dima]]></dc:creator><pubDate>Fri, 08 Feb 2008 10:47:31 GMT</pubDate></item><item><title><![CDATA[Reply to Datei in 512Byte Blöcken kopieren? on Fri, 08 Feb 2008 10:55:46 GMT]]></title><description><![CDATA[<p>Sollte das nicht eher so aussehen?</p>
<pre><code class="language-cpp">while(infile.read(buffer, 512))
        outfile.write(buffer, 512);
</code></pre>
<p>In einen int passen doch keine 512 Byte.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1451822</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1451822</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Fri, 08 Feb 2008 10:55:46 GMT</pubDate></item><item><title><![CDATA[Reply to Datei in 512Byte Blöcken kopieren? on Fri, 08 Feb 2008 11:31:40 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">void DateiKopieren(string&amp; inf, string&amp; outf)
{
	unsigned char buffer[512];
   fstream infile, outfile;
	infile.open(inf.c_str(), ios::in | ios::binary);
   outfile.open(outf.c_str(),ios::out | ios:: binary);
   while(infile.read(buffer, sizeof(buffer)))
		outfile.write(buffer, sizeof(buffer));
   infile.close();
   outfile.close();

}
</code></pre>
<p>Also mit dem Code oben werden Datein die Größer sind als 512Byte kopiert.<br />
Leider schneidet er den letzten unvollständigen Block von 512Byte ab.<br />
Wie könnte man das ändern, dass das lezte bzw. dateien, die kleiner sind wie 512Byte auch kopiert werden.</p>
<p>MfG<br />
Dima</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1451847</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1451847</guid><dc:creator><![CDATA[Dima]]></dc:creator><pubDate>Fri, 08 Feb 2008 11:31:40 GMT</pubDate></item><item><title><![CDATA[Reply to Datei in 512Byte Blöcken kopieren? on Fri, 08 Feb 2008 11:51:43 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">void DateiKopieren(const string&amp; inf, const string&amp; outf)
{
	char buffer[512];
	fstream infile, outfile;
	infile.open(inf.c_str(), ios::in | ios::binary);
	outfile.open(outf.c_str(),ios::out | ios:: binary);

	while(!infile.eof())
	{
		infile.read(buffer, sizeof(buffer));
		outfile.write(buffer, infile.gcount());
	}
	infile.close();
	outfile.close();
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1451870</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1451870</guid><dc:creator><![CDATA[Airdamn]]></dc:creator><pubDate>Fri, 08 Feb 2008 11:51:43 GMT</pubDate></item><item><title><![CDATA[Reply to Datei in 512Byte Blöcken kopieren? on Fri, 08 Feb 2008 12:01:12 GMT]]></title><description><![CDATA[<p>Das geht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /><br />
<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="🙂"
    /> Dankeschööööööön an alle. <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/1451883</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1451883</guid><dc:creator><![CDATA[Dima]]></dc:creator><pubDate>Fri, 08 Feb 2008 12:01:12 GMT</pubDate></item></channel></rss>