<?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[Binäre files]]></title><description><![CDATA[<p>Beispiel: binary write of double vector</p>
<pre><code>vector&lt;double&gt; d;
ofstream outfile(&quot;Signal.bin&quot;);
for(int i=0;i&lt;d.size();++i)
outfile.write((char *) &amp;d[i], sizeof(double));
</code></pre>
<p>Gibt es eine schönere Methode ohne FOR-SChleife und ohne das hässliche (char*)?</p>
<p>Wie lese ich eine binäre Datei in einem vector&lt;double&gt;?</p>
<p>Ich würde gerne so etwas schreiben auch für binäre Dateien:<br />
copy(istream_iterator&lt;double&gt;(infile),istream_iterator&lt;double&gt;(),back_inserter(d));</p>
<p>Danke Carmen</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/141355/binäre-files</link><generator>RSS for Node</generator><lastBuildDate>Mon, 31 Aug 2026 11:05:57 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/141355.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 21 Mar 2006 10:05:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Binäre files on Tue, 21 Mar 2006 10:05:10 GMT]]></title><description><![CDATA[<p>Beispiel: binary write of double vector</p>
<pre><code>vector&lt;double&gt; d;
ofstream outfile(&quot;Signal.bin&quot;);
for(int i=0;i&lt;d.size();++i)
outfile.write((char *) &amp;d[i], sizeof(double));
</code></pre>
<p>Gibt es eine schönere Methode ohne FOR-SChleife und ohne das hässliche (char*)?</p>
<p>Wie lese ich eine binäre Datei in einem vector&lt;double&gt;?</p>
<p>Ich würde gerne so etwas schreiben auch für binäre Dateien:<br />
copy(istream_iterator&lt;double&gt;(infile),istream_iterator&lt;double&gt;(),back_inserter(d));</p>
<p>Danke Carmen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1020943</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1020943</guid><dc:creator><![CDATA[carmen]]></dc:creator><pubDate>Tue, 21 Mar 2006 10:05:10 GMT</pubDate></item><item><title><![CDATA[Reply to Binäre files on Tue, 21 Mar 2006 12:21:18 GMT]]></title><description><![CDATA[<p>Ein Vektor speichert seine Elemente direkt hintereinander im RAM, also kannst du sie auch komplett übergeben:</p>
<pre><code class="language-cpp">outfile.write(&amp;d[0],sizeof(double)*d.size());
</code></pre>
<p>(und für die binäre Ein/Ausgabe mußt du dir wohl eigene Iteratoren schreiben, die normalen Stream-Iteratoren verwenden operator&gt;&gt; und &lt;&lt;)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1020999</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1020999</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 21 Mar 2006 12:21:18 GMT</pubDate></item><item><title><![CDATA[Reply to Binäre files on Tue, 21 Mar 2006 13:19:09 GMT]]></title><description><![CDATA[<p>Danke CStoll! Eine sehr gute Idee!<br />
Aber es funktioniert nur so:</p>
<pre><code>outfile.write((char *)&amp;d[0], sizeof(double)*d.size());
</code></pre>
<p>Wie schreibt man eigene Iteratoren??<br />
Wo finde ich Infos &amp; <strong>Beispiele</strong> darüber?</p>
<p>SCUZI!<br />
Ich bin Physikerin und komme von MatLab Programmierung in C++ neue Welt...<br />
Als Referenz habe ich mir die 3 Bücher von Jossutis bestellt...im &quot;The C++ Standard Library&quot; page 288 habe ich ein Chapter gefunden 'User-Defined Iterators', but ich brauche mehrere Beispiele...<br />
Danke ! Carmen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1021036</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1021036</guid><dc:creator><![CDATA[carmen]]></dc:creator><pubDate>Tue, 21 Mar 2006 13:19:09 GMT</pubDate></item><item><title><![CDATA[Reply to Binäre files on Tue, 21 Mar 2006 13:22:17 GMT]]></title><description><![CDATA[<p>carmen schrieb:</p>
<blockquote>
<p>Wie schreibt man eigene Iteratoren??<br />
Wo finde ich Infos &amp; <strong>Beispiele</strong> darüber?</p>
</blockquote>
<p>Du definierst dir eine eigene Klasse und verpasst ihr alle notwendigen Operatoren (kannst ja die Stream-Iteratoren der STL als Vorlage verwenden, wie das aussehen muß).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1021045</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1021045</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 21 Mar 2006 13:22:17 GMT</pubDate></item></channel></rss>