<?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[ofstream::write NULL Terminierung]]></title><description><![CDATA[<p>Hi,</p>
<pre><code>char test[3];
test[0]='a';
test[1]='b';
test[2]='\0';
file.write(test,3);
test[0]='a';
test[1]='b';
test[2]='\0';
file.write(test,3);
</code></pre>
<p>Ausgabe:</p>
<pre><code>扡愀b
</code></pre>
<pre><code>char test[2];
test[0]='a';
test[1]='b';
file.write(test,2);
test[0]='a';
test[1]='b';
file.write(test,2);
</code></pre>
<p>Ausgabe:</p>
<pre><code>abab
</code></pre>
<p>Kann mir vlt jemand erklären wieso die erste Ausgabe falsch ist und die zweite Richtig? Obwohl ich meinen würde die erste müsste richtig ausgeben un die zweite falsch?</p>
<p>Danke gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/330701/ofstream-write-null-terminierung</link><generator>RSS for Node</generator><lastBuildDate>Fri, 03 Jul 2026 02:32:14 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/330701.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 22 Jan 2015 14:39:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to ofstream::write NULL Terminierung on Thu, 22 Jan 2015 14:39:30 GMT]]></title><description><![CDATA[<p>Hi,</p>
<pre><code>char test[3];
test[0]='a';
test[1]='b';
test[2]='\0';
file.write(test,3);
test[0]='a';
test[1]='b';
test[2]='\0';
file.write(test,3);
</code></pre>
<p>Ausgabe:</p>
<pre><code>扡愀b
</code></pre>
<pre><code>char test[2];
test[0]='a';
test[1]='b';
file.write(test,2);
test[0]='a';
test[1]='b';
file.write(test,2);
</code></pre>
<p>Ausgabe:</p>
<pre><code>abab
</code></pre>
<p>Kann mir vlt jemand erklären wieso die erste Ausgabe falsch ist und die zweite Richtig? Obwohl ich meinen würde die erste müsste richtig ausgeben un die zweite falsch?</p>
<p>Danke gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2439053</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2439053</guid><dc:creator><![CDATA[Brause]]></dc:creator><pubDate>Thu, 22 Jan 2015 14:39:30 GMT</pubDate></item><item><title><![CDATA[Reply to ofstream::write NULL Terminierung on Thu, 22 Jan 2015 15:21:14 GMT]]></title><description><![CDATA[<p>Was soll an der ersten Ausgabe denn &quot;falsch&quot; sein?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2439063</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2439063</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Thu, 22 Jan 2015 15:21:14 GMT</pubDate></item><item><title><![CDATA[Reply to ofstream::write NULL Terminierung on Thu, 22 Jan 2015 18:46:25 GMT]]></title><description><![CDATA[<p>Dein Tool zum Überprüfen ist nicht geeignet oder falsch eingestellt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2439112</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2439112</guid><dc:creator><![CDATA[DirkB]]></dc:creator><pubDate>Thu, 22 Jan 2015 18:46:25 GMT</pubDate></item><item><title><![CDATA[Reply to ofstream::write NULL Terminierung on Fri, 23 Jan 2015 09:24:18 GMT]]></title><description><![CDATA[<p>Hi<br />
Naja das ist die Ausgabe die ich in einem File erhalte und die ist eben falsch?<br />
Mein Tool ist VS8.</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2439175</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2439175</guid><dc:creator><![CDATA[Brause]]></dc:creator><pubDate>Fri, 23 Jan 2015 09:24:18 GMT</pubDate></item><item><title><![CDATA[Reply to ofstream::write NULL Terminierung on Fri, 23 Jan 2015 12:04:39 GMT]]></title><description><![CDATA[<p>1. In welchem Universum ist das C und nicht C++? Und bin ich ein Teil dieses Universums?</p>
<p>2. (Ungültig, hatte einen Knick in der Optik).</p>
<p>3. Normalerweise gibt man immer kompilierbare Beispiele mit an, weil die Leute keinen Bock haben, sich da wieder einen Main-Wrapper drumzubauen Und ich kann's verstehen. Sehe ich bei dir auch nicht.</p>
<p>4. Und auf deine Ausgabe komme weder ich noch die anderen Paralleluniversen:</p>
<pre><code>#include &lt;fstream&gt;
#include &lt;iostream&gt;

int main(void)
{
        char test[3];
        std::ofstream file(&quot;bla&quot;);

        test[0]='a';
        test[1]='b';
        test[2]=0;

        file.write(test,3);
        std::cout.write(test,3);

        test[0]='a';
        test[1]='b';
        test[2]=0;

        file.write(test,3);
        std::cout.write(test,3);
        return 0;
}
</code></pre>
<p>Ausgabe uffer Konsole, durch <code>hd</code> gejagt:</p>
<pre><code>00000000  61 62 00 61 62 00                                 |ab.ab.|
00000006
</code></pre>
<p>Ausgabe inner Datei, durch <code>hd</code> gejagt:</p>
<pre><code>00000000  61 62 00 61 62 00                                 |ab.ab.|
00000006
</code></pre>
<p>Und was machen wir jetzt? Mit deinen Informationen kann zumindest ich das Problem nicht nachvollziehen. Entweder du legst da noch nach, oder du musst halt mit dem &quot;Verhalten&quot; bei dir leben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2439182</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2439182</guid><dc:creator><![CDATA[dachschaden]]></dc:creator><pubDate>Fri, 23 Jan 2015 12:04:39 GMT</pubDate></item><item><title><![CDATA[Reply to ofstream::write NULL Terminierung on Fri, 23 Jan 2015 10:50:20 GMT]]></title><description><![CDATA[<p>Brause schrieb:</p>
<blockquote>
<p>Hi<br />
Naja das ist die Ausgabe die ich in einem File erhalte und die ist eben falsch?<br />
Mein Tool ist VS8.</p>
</blockquote>
<p>Dann ist VS8 nicht geeignet um die Datei anzusehen. Bzw. die Einstellungen sind falsch.</p>
<p>Mein Verdacht:<br />
Da du in Version 1 Nullbytes schreibst, die in normalen ASCII-Texten nicht vorkommen, kann VS8 z.B. meinen, es handele sich um eine UTF16 Datei.</p>
<p>Nimm einen Hexviewer/Editor und schau damit in deine Datei.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2439190</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2439190</guid><dc:creator><![CDATA[DirkB]]></dc:creator><pubDate>Fri, 23 Jan 2015 10:50:20 GMT</pubDate></item><item><title><![CDATA[Reply to ofstream::write NULL Terminierung on Fri, 23 Jan 2015 20:29:48 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/u109509" rel="nofollow">SeppJ</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/f10" rel="nofollow">C (alle ISO-Standards)</a> in das Forum <a href="http://www.c-plusplus.net/forum/f15" rel="nofollow">C++ (alle ISO-Standards)</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/39405" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2439289</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2439289</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Fri, 23 Jan 2015 20:29:48 GMT</pubDate></item></channel></rss>