<?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[ueberladen von ofstream]]></title><description><![CDATA[<p>Hi,</p>
<p>ich habe folgendes Problem.</p>
<p>Habe mir selbst einen Bitmapheader geschrieben.<br />
(ICh weiss es gibt schon einen)</p>
<p>Jetzt wollte ich die Struktur mit einem Outstream an eine Datei uebergeben.</p>
<p>Leider hat der outstream meine Daten in Zeichenketten umgewandelt.</p>
<p>Sprich int wert 360000 belegt nicht 4 Byte sondern 6 ( 3 , 6, 0 ,0 ,0 ,0)<br />
Hab das jetzt folgendermassen umgangen</p>
<pre><code class="language-cpp">std::ostream &amp;operator&lt;&lt;(std::ostream &amp;ostr, const PILLE_BITMAPHEADER &amp;PiBi)
{
	ostr &lt;&lt; ((char*)&amp;PiBi.mType)[0];
	ostr &lt;&lt; ((char*)&amp;PiBi.mType)[1];
	ostr &lt;&lt; ((char*)&amp;PiBi.mFilesize)[0];
	ostr &lt;&lt; ((char*)&amp;PiBi.mFilesize)[1];
	ostr &lt;&lt; ((char*)&amp;PiBi.mFilesize)[2];
	ostr &lt;&lt; ((char*)&amp;PiBi.mFilesize)[3];
	ostr &lt;&lt; ((char*)&amp;PiBi.mReserved1)[0];
	ostr &lt;&lt; ((char*)&amp;PiBi.mReserved1)[1];
	ostr &lt;&lt; ((char*)&amp;PiBi.mReserved2)[0];
	ostr &lt;&lt; ((char*)&amp;PiBi.mReserved2)[1];
	ostr &lt;&lt; ((char*)&amp;PiBi.mOffset)[0];
	ostr &lt;&lt; ((char*)&amp;PiBi.mOffset)[1];
	ostr &lt;&lt; ((char*)&amp;PiBi.mOffset)[2];
	ostr &lt;&lt; ((char*)&amp;PiBi.mOffset)[3];

	return( ostr);
}
</code></pre>
<p>Das fuehlt sich aber irgendwie &quot;unsauber an&quot;, auch wenns klappt.</p>
<p>Hat irgendjemand Verbesserungsvorschlaege?</p>
<p>Und ein weiteres Problem <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
<p>Selber Header( standardkonform natuerlich)<br />
hat die Wertgroessen</p>
<p>short<br />
int<br />
short<br />
short<br />
int</p>
<p>macht als summe 14 byte</p>
<p>Weil aber auf das short gleich ein int kommt laesst der<br />
Rechner/Compiler/heinzelmaennchen da 2 byte frei weil er intern ja mit<br />
4 byte schritten arbeitet.</p>
<p>Wie kann ich die groesse vom rechner bestimmen lassen?<br />
Gebe momentan 14 manuell vor weil sizeof nicht funzt aber da gibts doch bestimmt alternativen oder?<br />
( sowas wie explicit size oder so)</p>
<p>Danke im voraus<br />
PIlger81</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/121976/ueberladen-von-ofstream</link><generator>RSS for Node</generator><lastBuildDate>Sat, 22 Aug 2026 21:51:53 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/121976.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 29 Sep 2005 06:44:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to ueberladen von ofstream on Thu, 29 Sep 2005 06:44:33 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich habe folgendes Problem.</p>
<p>Habe mir selbst einen Bitmapheader geschrieben.<br />
(ICh weiss es gibt schon einen)</p>
<p>Jetzt wollte ich die Struktur mit einem Outstream an eine Datei uebergeben.</p>
<p>Leider hat der outstream meine Daten in Zeichenketten umgewandelt.</p>
<p>Sprich int wert 360000 belegt nicht 4 Byte sondern 6 ( 3 , 6, 0 ,0 ,0 ,0)<br />
Hab das jetzt folgendermassen umgangen</p>
<pre><code class="language-cpp">std::ostream &amp;operator&lt;&lt;(std::ostream &amp;ostr, const PILLE_BITMAPHEADER &amp;PiBi)
{
	ostr &lt;&lt; ((char*)&amp;PiBi.mType)[0];
	ostr &lt;&lt; ((char*)&amp;PiBi.mType)[1];
	ostr &lt;&lt; ((char*)&amp;PiBi.mFilesize)[0];
	ostr &lt;&lt; ((char*)&amp;PiBi.mFilesize)[1];
	ostr &lt;&lt; ((char*)&amp;PiBi.mFilesize)[2];
	ostr &lt;&lt; ((char*)&amp;PiBi.mFilesize)[3];
	ostr &lt;&lt; ((char*)&amp;PiBi.mReserved1)[0];
	ostr &lt;&lt; ((char*)&amp;PiBi.mReserved1)[1];
	ostr &lt;&lt; ((char*)&amp;PiBi.mReserved2)[0];
	ostr &lt;&lt; ((char*)&amp;PiBi.mReserved2)[1];
	ostr &lt;&lt; ((char*)&amp;PiBi.mOffset)[0];
	ostr &lt;&lt; ((char*)&amp;PiBi.mOffset)[1];
	ostr &lt;&lt; ((char*)&amp;PiBi.mOffset)[2];
	ostr &lt;&lt; ((char*)&amp;PiBi.mOffset)[3];

	return( ostr);
}
</code></pre>
<p>Das fuehlt sich aber irgendwie &quot;unsauber an&quot;, auch wenns klappt.</p>
<p>Hat irgendjemand Verbesserungsvorschlaege?</p>
<p>Und ein weiteres Problem <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
<p>Selber Header( standardkonform natuerlich)<br />
hat die Wertgroessen</p>
<p>short<br />
int<br />
short<br />
short<br />
int</p>
<p>macht als summe 14 byte</p>
<p>Weil aber auf das short gleich ein int kommt laesst der<br />
Rechner/Compiler/heinzelmaennchen da 2 byte frei weil er intern ja mit<br />
4 byte schritten arbeitet.</p>
<p>Wie kann ich die groesse vom rechner bestimmen lassen?<br />
Gebe momentan 14 manuell vor weil sizeof nicht funzt aber da gibts doch bestimmt alternativen oder?<br />
( sowas wie explicit size oder so)</p>
<p>Danke im voraus<br />
PIlger81</p>
]]></description><link>https://www.c-plusplus.net/forum/post/882642</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/882642</guid><dc:creator><![CDATA[Pilger81]]></dc:creator><pubDate>Thu, 29 Sep 2005 06:44:33 GMT</pubDate></item><item><title><![CDATA[Reply to ueberladen von ofstream on Thu, 29 Sep 2005 06:48:40 GMT]]></title><description><![CDATA[<p>mit write kannst du binäre werte in den Stream schreiben.<br />
Und mit read sie wieder auslesen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/882648</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/882648</guid><dc:creator><![CDATA[phlox81]]></dc:creator><pubDate>Thu, 29 Sep 2005 06:48:40 GMT</pubDate></item><item><title><![CDATA[Reply to ueberladen von ofstream on Thu, 29 Sep 2005 06:50:41 GMT]]></title><description><![CDATA[<p>Das ist so einfach, ich geh mal schnell in die ecke und schaem mich <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="😞"
    /></p>
<p>Danke erstmal fuer die schnelle Antwort.<br />
(low level IO in C is einfacher aber ich will mir son bissl C++ angewoehnen <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="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/882649</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/882649</guid><dc:creator><![CDATA[Pilger81]]></dc:creator><pubDate>Thu, 29 Sep 2005 06:50:41 GMT</pubDate></item></channel></rss>