<?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[Anfänger, IOS::Binary]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich habe das Problem, dass mein &quot;Programm&quot; nur ohne ios::binary funktioniert.<br />
sobald ich ios::binary verwende wird eine 'exception' geschmissen.</p>
<pre><code class="language-cpp">int length;
    char * buffer;
    fstream f;

    f.open(argv[1], ios::binary);

    if(!f)
        cout &lt;&lt; &quot;problem with f&quot; &lt;&lt; endl;
    else
    {
        f.seekg(0, ios::end);

        length = f.tellg();

        f.seekg(0, ios::beg);

        buffer = new char[length];

        f.read(buffer, length);

        f.close();

        cout.write(buffer, length);
    }
</code></pre>
<p>kann mir jemand erklren woran das liegt?</p>
<p>edit://<br />
ich versuche eine .txt zu laden</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/260823/anfänger-ios-binary</link><generator>RSS for Node</generator><lastBuildDate>Mon, 07 Sep 2026 22:43:05 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/260823.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 09 Feb 2010 16:44:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Anfänger, IOS::Binary on Tue, 09 Feb 2010 16:45:16 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich habe das Problem, dass mein &quot;Programm&quot; nur ohne ios::binary funktioniert.<br />
sobald ich ios::binary verwende wird eine 'exception' geschmissen.</p>
<pre><code class="language-cpp">int length;
    char * buffer;
    fstream f;

    f.open(argv[1], ios::binary);

    if(!f)
        cout &lt;&lt; &quot;problem with f&quot; &lt;&lt; endl;
    else
    {
        f.seekg(0, ios::end);

        length = f.tellg();

        f.seekg(0, ios::beg);

        buffer = new char[length];

        f.read(buffer, length);

        f.close();

        cout.write(buffer, length);
    }
</code></pre>
<p>kann mir jemand erklren woran das liegt?</p>
<p>edit://<br />
ich versuche eine .txt zu laden</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1853242</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1853242</guid><dc:creator><![CDATA[freak131]]></dc:creator><pubDate>Tue, 09 Feb 2010 16:45:16 GMT</pubDate></item><item><title><![CDATA[Reply to Anfänger, IOS::Binary on Tue, 09 Feb 2010 17:19:28 GMT]]></title><description><![CDATA[<pre><code>f.open(argv[1],  ios::in | ios::binary);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1853256</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1853256</guid><dc:creator><![CDATA[NN]]></dc:creator><pubDate>Tue, 09 Feb 2010 17:19:28 GMT</pubDate></item><item><title><![CDATA[Reply to Anfänger, IOS::Binary on Tue, 09 Feb 2010 17:32:37 GMT]]></title><description><![CDATA[<p>Nä, fstream ergänzt von alleine <code>ios_base::in | ios_base::out</code> .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1853259</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1853259</guid><dc:creator><![CDATA[Ad aCTa]]></dc:creator><pubDate>Tue, 09 Feb 2010 17:32:37 GMT</pubDate></item><item><title><![CDATA[Reply to Anfänger, IOS::Binary on Tue, 09 Feb 2010 17:38:39 GMT]]></title><description><![CDATA[<p>Ad aCTa schrieb:</p>
<blockquote>
<p>Nä, fstream ergänzt von alleine <code>ios_base::in | ios_base::out</code> .</p>
</blockquote>
<p>Das stimmt nicht! Er gab ios::binary an und das wurde nicht ergänzt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1853261</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1853261</guid><dc:creator><![CDATA[NN]]></dc:creator><pubDate>Tue, 09 Feb 2010 17:38:39 GMT</pubDate></item><item><title><![CDATA[Reply to Anfänger, IOS::Binary on Tue, 09 Feb 2010 18:16:14 GMT]]></title><description><![CDATA[<p>ich hatte das gefühl, er läd irgendwas aus dem ram oder etc.</p>
<p>woher kommen die daten dann?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1853270</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1853270</guid><dc:creator><![CDATA[freak131]]></dc:creator><pubDate>Tue, 09 Feb 2010 18:16:14 GMT</pubDate></item><item><title><![CDATA[Reply to Anfänger, IOS::Binary on Tue, 09 Feb 2010 19:57:14 GMT]]></title><description><![CDATA[<p>Wenn du binary angibts, dann werden Steuerzeichen für Texte ignoriert, dass heist es kann schon sein, dass du merkwürdige Zeichen ausgegeben bekommst. Ansonsten kann man nur vermuten das argv[1] kein gescheiter Pfad ist, welche aber ohne meckern gefressen wird. Probier es mal mit konstantem char* z.B.</p>
<pre><code class="language-cpp">f.open(&quot;C:\\Test.txt&quot;,  ios_base::out |ios_base::in | ios_base::binary);
</code></pre>
<p>Das ios_base::out ist eingentlich überflüssig, schadet aber hier nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1853311</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1853311</guid><dc:creator><![CDATA[JaykopX]]></dc:creator><pubDate>Tue, 09 Feb 2010 19:57:14 GMT</pubDate></item></channel></rss>