<?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[wchar_t und fstream Problem.]]></title><description><![CDATA[<p>Wenn ich mt den folgenden Zeilen in eine Datei schreibe:</p>
<pre><code class="language-cpp">wchar_t fh[2];
fh[0] = 'c';
fh[1] = 'y';
file.write((wchar_t*) &amp;fh[0], sizeof(wchar_t));
file.write((wchar_t*) &amp;fh[1], sizeof(wchar_t));

unsigned long size = 64;
file.write((wchar_t*) &amp;size, sizeof(long));
</code></pre>
<p>und wieder auslesen will:</p>
<pre><code class="language-cpp">wchar_t fh[2];
file.read((wchar_t*) &amp;fh[0], sizeof(wchar_t));
file.read((wchar_t*) &amp;fh[1], sizeof(wchar_t));

if(file.eof())
   std::wcout &lt;&lt; &quot;EOF&quot;;
// EOF tritt ein                                 //
// ist hier die Datei zu Ende? Warum             //
// Wenn ich char nehme, tritt das Prob nicht auf //

unsigned long size;
file.read((wchar_t*) &amp;size, sizeof(long));
</code></pre>
<p>Würde mich seht über eine schnelle Antwort freuen.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/144232/wchar_t-und-fstream-problem</link><generator>RSS for Node</generator><lastBuildDate>Wed, 02 Sep 2026 14:50:42 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/144232.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 16 Apr 2006 08:50:18 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to wchar_t und fstream Problem. on Sun, 16 Apr 2006 08:50:18 GMT]]></title><description><![CDATA[<p>Wenn ich mt den folgenden Zeilen in eine Datei schreibe:</p>
<pre><code class="language-cpp">wchar_t fh[2];
fh[0] = 'c';
fh[1] = 'y';
file.write((wchar_t*) &amp;fh[0], sizeof(wchar_t));
file.write((wchar_t*) &amp;fh[1], sizeof(wchar_t));

unsigned long size = 64;
file.write((wchar_t*) &amp;size, sizeof(long));
</code></pre>
<p>und wieder auslesen will:</p>
<pre><code class="language-cpp">wchar_t fh[2];
file.read((wchar_t*) &amp;fh[0], sizeof(wchar_t));
file.read((wchar_t*) &amp;fh[1], sizeof(wchar_t));

if(file.eof())
   std::wcout &lt;&lt; &quot;EOF&quot;;
// EOF tritt ein                                 //
// ist hier die Datei zu Ende? Warum             //
// Wenn ich char nehme, tritt das Prob nicht auf //

unsigned long size;
file.read((wchar_t*) &amp;size, sizeof(long));
</code></pre>
<p>Würde mich seht über eine schnelle Antwort freuen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1038329</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1038329</guid><dc:creator><![CDATA[Tc++H]]></dc:creator><pubDate>Sun, 16 Apr 2006 08:50:18 GMT</pubDate></item><item><title><![CDATA[Reply to wchar_t und fstream Problem. on Sun, 16 Apr 2006 09:05:17 GMT]]></title><description><![CDATA[<p>Tc++H schrieb:</p>
<blockquote>
<p>Wenn ich mt den folgenden Zeilen in eine Datei schreibe:</p>
<p>[cpp]wchar_t fh[2];<br />
fh[0] = 'c';<br />
fh[1] = 'y';<br />
file.write((wchar_t*) &amp;fh[0], sizeof(wchar_t));<br />
file.write((wchar_t*) &amp;fh[1], sizeof(wchar_t));</p>
</blockquote>
<p>Welchen Char-Type verwendet file? Und mit welchen Flags öffnest du file?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1038335</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1038335</guid><dc:creator><![CDATA[HumeSikkins]]></dc:creator><pubDate>Sun, 16 Apr 2006 09:05:17 GMT</pubDate></item><item><title><![CDATA[Reply to wchar_t und fstream Problem. on Sun, 16 Apr 2006 09:33:03 GMT]]></title><description><![CDATA[<p>schreiben:</p>
<pre><code class="language-cpp">std::basic_fstream&lt;wchar_t&gt; file;
file.open(filename.c_str(), std::ios_base::out | std::ios_base::binary);
</code></pre>
<p>lesen:</p>
<pre><code class="language-cpp">std::basic_fstream&lt;wchar_t&gt; file;
file.open(filename.c_str(), std::ios_base::in | std::ios_base::binary);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1038349</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1038349</guid><dc:creator><![CDATA[Tc++H]]></dc:creator><pubDate>Sun, 16 Apr 2006 09:33:03 GMT</pubDate></item><item><title><![CDATA[Reply to wchar_t und fstream Problem. on Sun, 16 Apr 2006 13:57:45 GMT]]></title><description><![CDATA[<p>Hat jemand schon eine Idee?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1038468</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1038468</guid><dc:creator><![CDATA[Tc++H]]></dc:creator><pubDate>Sun, 16 Apr 2006 13:57:45 GMT</pubDate></item><item><title><![CDATA[Reply to wchar_t und fstream Problem. on Sun, 16 Apr 2006 16:31:49 GMT]]></title><description><![CDATA[<p>Tc++H schrieb:</p>
<blockquote>
<p>Hat jemand schon eine Idee?</p>
</blockquote>
<p>Wenn du einen wide-Stream verwendest, musst du die Anzahl der zu schreibenden Zeichen auch relativ zu sizeof(wchar_t) berechnen.<br />
So sollte es gehen:</p>
<pre><code class="language-cpp">wchar_t fh[2];
fh[0] = 'c';
fh[1] = 'y';
file.write(&amp;fh[0], 1);
file.write(&amp;fh[1], 1);

unsigned long size = 64;
file.write((wchar_t*) &amp;size, sizeof(long) / sizeof(wchar_t));
</code></pre>
<p>Lesen:</p>
<pre><code class="language-cpp">wchar_t fh[2];
file.read(&amp;fh[0], 1);
file.read(&amp;fh[1], 1);

unsigned long size;
file.read((wchar_t*) &amp;size, sizeof(long) / sizeof(wchar_t));
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1038575</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1038575</guid><dc:creator><![CDATA[HumeSikkins]]></dc:creator><pubDate>Sun, 16 Apr 2006 16:31:49 GMT</pubDate></item><item><title><![CDATA[Reply to wchar_t und fstream Problem. on Sun, 16 Apr 2006 17:02:40 GMT]]></title><description><![CDATA[<p>Daran hatte ich auch schonmal gedacht.</p>
<p>vielen Dank.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1038595</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1038595</guid><dc:creator><![CDATA[Tc++H]]></dc:creator><pubDate>Sun, 16 Apr 2006 17:02:40 GMT</pubDate></item><item><title><![CDATA[Reply to wchar_t und fstream Problem. on Sun, 16 Apr 2006 17:53:05 GMT]]></title><description><![CDATA[<p>Klappt irgendwie immer noch nicht: hier ist mal der gesamt Code:</p>
<pre><code class="language-cpp">bool encrypth(const std::basic_string&lt;wchar_t&gt;&amp; str, const std::basic_string&lt;wchar_t&gt;&amp; filename)
{
	std::basic_fstream&lt;wchar_t&gt; file;
	file.open(filename.c_str(), std::ios_base::out | std::ios_base::binary);
	if(!file)
		return false;

	wchar_t fh[2];
	fh[0] = 'c';
	fh[1] = 'y';
	file.write((wchar_t*) &amp;fh[0], 1);
	file.write((wchar_t*) &amp;fh[1], 1);

	unsigned long size = static_cast&lt;unsigned long&gt;(str.length() * 4);
	file.write((wchar_t*) &amp;size, sizeof(unsigned long) / sizeof(wchar_t));

	unsigned long y;
	for(unsigned long i = 0; i &lt; str.length(); i ++)
	{
		y = (str[i] + i) * (i + 10);
		file.write((wchar_t*) &amp;y, sizeof(unsigned long) / sizeof(wchar_t));
	}

	return true;
}

bool decrypth(std::basic_string&lt;wchar_t&gt;&amp; str, const std::basic_string&lt;wchar_t&gt;&amp; filename)
{
	std::basic_fstream&lt;wchar_t&gt; file;
	file.open(filename.c_str(), std::ios_base::in | std::ios_base::binary);
	if(!file)
		return false;

	wchar_t fh[2];
	file.read((wchar_t*) &amp;fh[0], 1);
	file.read((wchar_t*) &amp;fh[1], 1);

	unsigned long size;
	file.read((wchar_t*) &amp;size, sizeof(unsigned long) / sizeof(wchar_t));

	unsigned long y;
	for(unsigned long i = 0; i &lt; size / 4; i ++)
	{
		std::wcout &lt;&lt; L&quot;EOF&quot;; // tritt ab hier immer wieder auf...
		file.read((wchar_t*) &amp;y, sizeof(unsigned long) / sizeof(wchar_t));
		std::wcout &lt;&lt; y &lt;&lt; L&quot; &quot;;
		str += static_cast&lt;wchar_t&gt;(y / (i + 10) - i);
	}

	return true;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1038626</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1038626</guid><dc:creator><![CDATA[ff]]></dc:creator><pubDate>Sun, 16 Apr 2006 17:53:05 GMT</pubDate></item><item><title><![CDATA[Reply to wchar_t und fstream Problem. on Mon, 17 Apr 2006 16:40:58 GMT]]></title><description><![CDATA[<p>Warum so kompliziert?<br />
machs doch einfach so:</p>
<pre><code class="language-cpp">fwstream Test(bla.bla , ios::in | ios::out)
wchar_t wide;
//so um ein wide character zu schreiben: 
Test &lt;&lt; wide;
//so um einen zu lesen:
Test &gt;&gt; wide;
</code></pre>
<p>musst halt immer im auge behalten ob der Dateizeiger dort ist wo du ihn willst</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1039181</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1039181</guid><dc:creator><![CDATA[tobZel]]></dc:creator><pubDate>Mon, 17 Apr 2006 16:40:58 GMT</pubDate></item></channel></rss>