<?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[fstream fehler?]]></title><description><![CDATA[<p>Hey,<br />
ich habe ein Problem mit einem fstream. Ich möchte den Inhalt einer Datei in einen stringstream packen. Dies klappt so aber leider nicht:</p>
<pre><code class="language-cpp">fstream fHash(&quot;D:\\hash.txt&quot;, ios::in);
	if(fHash.is_open())
	{
		stringstream ssHash;
		while(!fHash.eof())
		{
			char ac[2];
			fHash.read(ac, 1);
			ac[1]='\0';
			ssHash &lt;&lt; ac;
		}
		fHash.close();
	}
</code></pre>
<p>Aus irgendeinem Grund, den ich nicht verstehen kann, wir immer ein char zu viel ausgelesen. (Dateigröße ist 2048 bytes, 2049 zeichen sind dann bei dieser Version am Ende im stream...)</p>
<p>Diese Version klappt aber ohne Probleme.</p>
<pre><code class="language-cpp">fstream fHash(&quot;D:\\hash.txt&quot;, ios::in);
	if(fHash.is_open())
	{
		stringstream ssHash;
		char ac[2];
		ac[1]='\0';
		while(fHash.read(ac, 1))
		{
			ssHash &lt;&lt; ac;
		}
		fHash.close();
	}
</code></pre>
<p>Wo ist mein Fehler?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/153631/fstream-fehler</link><generator>RSS for Node</generator><lastBuildDate>Mon, 07 Sep 2026 14:06:43 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/153631.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 19 Jul 2006 09:08:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to fstream fehler? on Wed, 19 Jul 2006 09:08:44 GMT]]></title><description><![CDATA[<p>Hey,<br />
ich habe ein Problem mit einem fstream. Ich möchte den Inhalt einer Datei in einen stringstream packen. Dies klappt so aber leider nicht:</p>
<pre><code class="language-cpp">fstream fHash(&quot;D:\\hash.txt&quot;, ios::in);
	if(fHash.is_open())
	{
		stringstream ssHash;
		while(!fHash.eof())
		{
			char ac[2];
			fHash.read(ac, 1);
			ac[1]='\0';
			ssHash &lt;&lt; ac;
		}
		fHash.close();
	}
</code></pre>
<p>Aus irgendeinem Grund, den ich nicht verstehen kann, wir immer ein char zu viel ausgelesen. (Dateigröße ist 2048 bytes, 2049 zeichen sind dann bei dieser Version am Ende im stream...)</p>
<p>Diese Version klappt aber ohne Probleme.</p>
<pre><code class="language-cpp">fstream fHash(&quot;D:\\hash.txt&quot;, ios::in);
	if(fHash.is_open())
	{
		stringstream ssHash;
		char ac[2];
		ac[1]='\0';
		while(fHash.read(ac, 1))
		{
			ssHash &lt;&lt; ac;
		}
		fHash.close();
	}
</code></pre>
<p>Wo ist mein Fehler?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1100237</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1100237</guid><dc:creator><![CDATA[N0=b]]></dc:creator><pubDate>Wed, 19 Jul 2006 09:08:44 GMT</pubDate></item><item><title><![CDATA[Reply to fstream fehler? on Wed, 19 Jul 2006 09:59:00 GMT]]></title><description><![CDATA[<p>eof() liefert erst dann true, wenn read schon einmal fehlgeschlagen ist.</p>
<p>Edit: 3000!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1100263</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1100263</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Wed, 19 Jul 2006 09:59:00 GMT</pubDate></item><item><title><![CDATA[Reply to fstream fehler? on Wed, 19 Jul 2006 09:58:49 GMT]]></title><description><![CDATA[<p>Und all' die Jahre nehm ich eof() und habe nichts gemerkt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /><br />
Egal, danke <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="🙂"
    /><br />
cya</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1100264</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1100264</guid><dc:creator><![CDATA[N0=b]]></dc:creator><pubDate>Wed, 19 Jul 2006 09:58:49 GMT</pubDate></item><item><title><![CDATA[Reply to fstream fehler? on Wed, 19 Jul 2006 09:58:59 GMT]]></title><description><![CDATA[<p><a href="http://fara.cs.uni-potsdam.de/~kaufmann/?page=GenCppFaqs&amp;faq=eof#Answ" rel="nofollow">http://fara.cs.uni-potsdam.de/~kaufmann/?page=GenCppFaqs&amp;faq=eof#Answ</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1100265</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1100265</guid><dc:creator><![CDATA[joomoo]]></dc:creator><pubDate>Wed, 19 Jul 2006 09:58:59 GMT</pubDate></item></channel></rss>