<?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[byte aus int nach char-Problem]]></title><description><![CDATA[<p>hi,<br />
ich möchte aus einem int-wert das niederwertigste byte in ein char speichern:</p>
<pre><code>cout&lt;&lt;&quot;sb4:&quot;&lt;&lt;hex&lt;&lt;int(send_buffer.seq_n%0x100)&lt;&lt;dec&lt;&lt;endl;
pkt_send.data[7]=int(send_buffer.seq_n%0x100);
cout&lt;&lt;&quot;sb4:&quot;&lt;&lt;hex&lt;&lt;int(pkt_send.data[7])&lt;&lt;dec&lt;&lt;endl;
</code></pre>
<p>dabei ist<br />
&quot;send_buffer.seq_n&quot; ein int und<br />
&quot;pkt_send.data[7]&quot; ein char</p>
<p>während der Laufzeit ist 'send_buffer.seq_n' mit 1237(0x04d5) belegt und jetzt soll &quot;0xd5&quot; in pkt_send.data[7] landen. was rauskommt ist aber 0xffffffd5.<br />
Das erste cout zeigt auch das richtige an (d5),<br />
aber bei der zweiten Ausgabe halt 0xffffffd5.<br />
wäre schön, wenn mir jemand weiterhelfen könnte.<br />
danke</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/137665/byte-aus-int-nach-char-problem</link><generator>RSS for Node</generator><lastBuildDate>Sat, 29 Aug 2026 19:40:23 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/137665.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 19 Feb 2006 16:40:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to byte aus int nach char-Problem on Sun, 19 Feb 2006 16:40:38 GMT]]></title><description><![CDATA[<p>hi,<br />
ich möchte aus einem int-wert das niederwertigste byte in ein char speichern:</p>
<pre><code>cout&lt;&lt;&quot;sb4:&quot;&lt;&lt;hex&lt;&lt;int(send_buffer.seq_n%0x100)&lt;&lt;dec&lt;&lt;endl;
pkt_send.data[7]=int(send_buffer.seq_n%0x100);
cout&lt;&lt;&quot;sb4:&quot;&lt;&lt;hex&lt;&lt;int(pkt_send.data[7])&lt;&lt;dec&lt;&lt;endl;
</code></pre>
<p>dabei ist<br />
&quot;send_buffer.seq_n&quot; ein int und<br />
&quot;pkt_send.data[7]&quot; ein char</p>
<p>während der Laufzeit ist 'send_buffer.seq_n' mit 1237(0x04d5) belegt und jetzt soll &quot;0xd5&quot; in pkt_send.data[7] landen. was rauskommt ist aber 0xffffffd5.<br />
Das erste cout zeigt auch das richtige an (d5),<br />
aber bei der zweiten Ausgabe halt 0xffffffd5.<br />
wäre schön, wenn mir jemand weiterhelfen könnte.<br />
danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/997976</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/997976</guid><dc:creator><![CDATA[schnoop]]></dc:creator><pubDate>Sun, 19 Feb 2006 16:40:38 GMT</pubDate></item><item><title><![CDATA[Reply to byte aus int nach char-Problem on Sun, 19 Feb 2006 17:22:38 GMT]]></title><description><![CDATA[<p>Hm, ich versteh den Syntax von deinem Quellcode zwar nicht ganz aber ich würde das niederwertigste Byte ganz einfach so extrahieren:</p>
<p>short hex = 0x04d5;<br />
char data = hex;</p>
<p>(sry C/C++ code rahmen funktioniert bei mir nicht)<br />
data hat (bei mir zumindest) jetzt den wert 0xd5.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/998028</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/998028</guid><dc:creator><![CDATA[dielösung]]></dc:creator><pubDate>Sun, 19 Feb 2006 17:22:38 GMT</pubDate></item><item><title><![CDATA[Reply to byte aus int nach char-Problem on Sun, 19 Feb 2006 17:24:48 GMT]]></title><description><![CDATA[<p>p.s. 0x04d5 ist ein short-value und kein int-value <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/998033</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/998033</guid><dc:creator><![CDATA[dielösung]]></dc:creator><pubDate>Sun, 19 Feb 2006 17:24:48 GMT</pubDate></item><item><title><![CDATA[Reply to byte aus int nach char-Problem on Sun, 19 Feb 2006 20:23:56 GMT]]></title><description><![CDATA[<p>danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/998157</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/998157</guid><dc:creator><![CDATA[schnoop]]></dc:creator><pubDate>Sun, 19 Feb 2006 20:23:56 GMT</pubDate></item></channel></rss>