<?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[fscanf oder fread]]></title><description><![CDATA[<p>was ist eurer meinung nach effinzienter:<br />
fscanf oder fread</p>
<p>oder in welchen fall wendet man das eine an und das andere nicht?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/136242/fscanf-oder-fread</link><generator>RSS for Node</generator><lastBuildDate>Sat, 29 Aug 2026 11:19:00 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/136242.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 08 Feb 2006 14:57:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to fscanf oder fread on Wed, 08 Feb 2006 14:57:38 GMT]]></title><description><![CDATA[<p>was ist eurer meinung nach effinzienter:<br />
fscanf oder fread</p>
<p>oder in welchen fall wendet man das eine an und das andere nicht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/989393</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/989393</guid><dc:creator><![CDATA[asr]]></dc:creator><pubDate>Wed, 08 Feb 2006 14:57:38 GMT</pubDate></item><item><title><![CDATA[Reply to fscanf oder fread on Wed, 08 Feb 2006 15:16:03 GMT]]></title><description><![CDATA[<p>Man verwendet std::[i]fstream::operator &gt;&gt; oder std::[i]fstream::read. Den Operator beim formatierten einlesen, und read beim binären einlesen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/989407</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/989407</guid><dc:creator><![CDATA[OMFG]]></dc:creator><pubDate>Wed, 08 Feb 2006 15:16:03 GMT</pubDate></item><item><title><![CDATA[Reply to fscanf oder fread on Wed, 08 Feb 2006 15:34:53 GMT]]></title><description><![CDATA[<p>hab eine binäre datei</p>
]]></description><link>https://www.c-plusplus.net/forum/post/989428</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/989428</guid><dc:creator><![CDATA[asr]]></dc:creator><pubDate>Wed, 08 Feb 2006 15:34:53 GMT</pubDate></item><item><title><![CDATA[Reply to fscanf oder fread on Wed, 08 Feb 2006 18:24:59 GMT]]></title><description><![CDATA[<p>fscanf parst die Daten, fread liest sie. Kurz gesagt fscanf ist für Textdateien und fread für binäre Dateien besser geeignet...</p>
<p>EDIT: Für fstreams gibts auch blockorientierte Lese- und Schreibfunktionen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/989598</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/989598</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Wed, 08 Feb 2006 18:24:59 GMT</pubDate></item><item><title><![CDATA[Reply to fscanf oder fread on Thu, 09 Feb 2006 09:15:19 GMT]]></title><description><![CDATA[<p>ich habe folgende zwei sachen getestet:</p>
<pre><code class="language-cpp">erstens:
long size = 0;
fread(&amp;size, sizeof(long), 1, file);

zweitens:
long size = 0;
fscanf(file, &quot;%ld&quot;, size);
</code></pre>
<p>wobei ich mit fread den richtigen wert zurück bekomme.<br />
bei fscanf einfach nur 0</p>
]]></description><link>https://www.c-plusplus.net/forum/post/989887</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/989887</guid><dc:creator><![CDATA[asr]]></dc:creator><pubDate>Thu, 09 Feb 2006 09:15:19 GMT</pubDate></item><item><title><![CDATA[Reply to fscanf oder fread on Thu, 09 Feb 2006 09:18:22 GMT]]></title><description><![CDATA[<p>Weil fscanf die Daten parst, und fread liest nur.</p>
<p>Mit fscanf liest Du hier eine als Text gespeicherte Zahl ein wobei fscanf entscheidet wie lang diese Zahl ist (Die Ziffer '1', gefolgt von der Ziffer '3', ... bis zu einer nicht-Ziffer). Mit fread liest Du genau vier Bytes (meistens) binär ein und interpretierst diese Daten als Long.</p>
<p>Ach: Bei fscanf muss auch die Adresse übergeben werden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/989892</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/989892</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Thu, 09 Feb 2006 09:18:22 GMT</pubDate></item><item><title><![CDATA[Reply to fscanf oder fread on Thu, 09 Feb 2006 09:24:47 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/10648">@LordJaxom</a>: stimmt, aber</p>
<pre><code class="language-cpp">fscanf(file, &quot;%ld&quot;, &amp;size);
</code></pre>
<p>tut es leider auch nicht.<br />
bleich ich wohl beim fread...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/989897</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/989897</guid><dc:creator><![CDATA[asr]]></dc:creator><pubDate>Thu, 09 Feb 2006 09:24:47 GMT</pubDate></item><item><title><![CDATA[Reply to fscanf oder fread on Thu, 09 Feb 2006 09:28:37 GMT]]></title><description><![CDATA[<p>asr schrieb:</p>
<blockquote>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/10648">@LordJaxom</a>: stimmt, aber</p>
<pre><code class="language-cpp">fscanf(file, &quot;%ld&quot;, &amp;size);
</code></pre>
<p>tut es leider auch nicht.</p>
</blockquote>
<p>Das kommt ganz darauf an, wie deine Daten in der Datei drinstehen - fscanf() erwartet keine Binärdaten, sondern eine textuell dargestellte Zahl (also z.B. &quot;4711&quot; oder &quot;123456&quot;).</p>
<blockquote>
<p>bleich ich wohl beim fread...</p>
</blockquote>
<p>Ich hätte einen besseren Vorschlag: nimm fstream::read() <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>
]]></description><link>https://www.c-plusplus.net/forum/post/989899</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/989899</guid><dc:creator><![CDATA[CStoll (off)]]></dc:creator><pubDate>Thu, 09 Feb 2006 09:28:37 GMT</pubDate></item><item><title><![CDATA[Reply to fscanf oder fread on Thu, 09 Feb 2006 09:44:08 GMT]]></title><description><![CDATA[<p>asr schrieb:</p>
<blockquote>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/10648">@LordJaxom</a>: stimmt, aber</p>
<pre><code class="language-cpp">fscanf(file, &quot;%ld&quot;, &amp;size);
</code></pre>
<p>tut es leider auch nicht.<br />
bleich ich wohl beim fread...</p>
</blockquote>
<p>Sagte ich nicht dass fread die Daten binär liest, mit fester Länge, und fscanf eine als Text gespeicherte Zahl <strong>interpretiert</strong>?</p>
<p>Soll ich es Dir aufmalen? <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>Das ist Deine Datei:</p>
<pre><code>1240,26,122
</code></pre>
<p>Wenn Du mit fscanf liest, wird <strong>interpretiert</strong>. Er liest ein Zeichen, merkt dass das eine Ziffer ist, liest noch ein Zeichen, usw, bis er merkt dass das Komma keine Ziffer mehr ist. Dann rechnet er den Text &quot;1240&quot; um in die Zahl Eintausendzweihundertvierzig.</p>
<p>fread liest vier Bytes als long ein. Das sind zufällig auch die 1, die 2, die 4 und die 0. Aber nicht die <strong>Zeichen</strong> 1, 2, 4 und 0 stehen hinterher in der long-Variable, sondern die Zahl, die durch die ASCII-Codes dieser vier Ziffern, interpretiert als long, gebildet wird. (Die Zahl lautet in dem Fall 808727089).</p>
<p>Anyway: Weisst Du was in Deiner Datei, die Du liest, steht? Hast Du Dir die mal mit nem Editor angeschaut?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/989923</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/989923</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Thu, 09 Feb 2006 09:44:08 GMT</pubDate></item><item><title><![CDATA[Reply to fscanf oder fread on Thu, 09 Feb 2006 09:51:01 GMT]]></title><description><![CDATA[<p>o.k. habs kapiert.</p>
<p>hab eine binärdatei und weiss auch was drin steht. seh dann auch ein, dass es fscanf nicht tut.</p>
<p>thx</p>
]]></description><link>https://www.c-plusplus.net/forum/post/989932</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/989932</guid><dc:creator><![CDATA[asr]]></dc:creator><pubDate>Thu, 09 Feb 2006 09:51:01 GMT</pubDate></item></channel></rss>