<?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[Aus 2 bytes(char) einen 16 bit oder int machen]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich habe ein problem und zwar ich möchte zwei char(mit hexadezimal Werte) zusammen fügen und das Ergebnisse als int haben.</p>
<p>so versuche ich es und bekomme aber falsche Ergebnisse</p>
<pre><code class="language-cpp">int Syst;

Syst= (OctetStuffReceiverfunt.str[10]&lt;&lt; 8)| (0xFF&amp;OctetStuffReceiverfunt.str[11]);
</code></pre>
<p>danke für eure Hilfe</p>
<p>Ryoban</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/308708/aus-2-bytes-char-einen-16-bit-oder-int-machen</link><generator>RSS for Node</generator><lastBuildDate>Wed, 05 Aug 2026 15:18:43 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/308708.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 03 Oct 2012 10:25:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Aus 2 bytes(char) einen 16 bit oder int machen on Wed, 03 Oct 2012 10:25:50 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich habe ein problem und zwar ich möchte zwei char(mit hexadezimal Werte) zusammen fügen und das Ergebnisse als int haben.</p>
<p>so versuche ich es und bekomme aber falsche Ergebnisse</p>
<pre><code class="language-cpp">int Syst;

Syst= (OctetStuffReceiverfunt.str[10]&lt;&lt; 8)| (0xFF&amp;OctetStuffReceiverfunt.str[11]);
</code></pre>
<p>danke für eure Hilfe</p>
<p>Ryoban</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2256700</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2256700</guid><dc:creator><![CDATA[ryoban]]></dc:creator><pubDate>Wed, 03 Oct 2012 10:25:50 GMT</pubDate></item><item><title><![CDATA[Reply to Aus 2 bytes(char) einen 16 bit oder int machen on Wed, 03 Oct 2012 10:47:14 GMT]]></title><description><![CDATA[<p>endianess beruecksichtigt ? oder was meinst du mit falschem wert ?<br />
ist der inhalt eines char z.b. '2' oder willst du wirklich den binaerwert verwenden ?</p>
<p>Meep Meep</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2256704</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2256704</guid><dc:creator><![CDATA[Meep Meep]]></dc:creator><pubDate>Wed, 03 Oct 2012 10:47:14 GMT</pubDate></item><item><title><![CDATA[Reply to Aus 2 bytes(char) einen 16 bit oder int machen on Wed, 03 Oct 2012 11:09:05 GMT]]></title><description><![CDATA[<p>hallo Meep Meep</p>
<p>Meep Meep schrieb:</p>
<blockquote>
<p>endianess beruecksichtigt ? oder was meinst du mit falschem wert ?<br />
ist der inhalt eines char z.b. '2' oder willst du wirklich den binaerwert verwenden ?</p>
<p>Meep Meep</p>
</blockquote>
<p>ich möchte zum Beispiel aus 0x00 und 0x91 das int 145 bekommen dh Syst= 145<br />
ich bekomme aber -28160.</p>
<p>Grüß</p>
<p>Ryoban</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2256710</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2256710</guid><dc:creator><![CDATA[ryoban]]></dc:creator><pubDate>Wed, 03 Oct 2012 11:09:05 GMT</pubDate></item><item><title><![CDATA[Reply to Aus 2 bytes(char) einen 16 bit oder int machen on Wed, 03 Oct 2012 11:32:30 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;limits&gt;

int unsigned makeword( char unsigned const a, char unsigned const b )
{
        return ( a &lt;&lt; std::numeric_limits&lt; char unsigned &gt;::digits ) | b;
}
</code></pre>
<p>funktioniert toll.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2256714</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2256714</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Wed, 03 Oct 2012 11:32:30 GMT</pubDate></item><item><title><![CDATA[Reply to Aus 2 bytes(char) einen 16 bit oder int machen on Wed, 03 Oct 2012 11:57:27 GMT]]></title><description><![CDATA[<p>Du musst deine chars nur zo unsigned char konvertieren, denn ansonsten werden bei der direkten Konvertierung zu int die neuen Stellen mit dem Vorzeichen bit gefuellt anstatt mit mit den gewollten Nullen (wenn char als signed betrachtet wird).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2256720</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2256720</guid><dc:creator><![CDATA[Bitexperte]]></dc:creator><pubDate>Wed, 03 Oct 2012 11:57:27 GMT</pubDate></item><item><title><![CDATA[Reply to Aus 2 bytes(char) einen 16 bit oder int machen on Wed, 03 Oct 2012 15:47:25 GMT]]></title><description><![CDATA[<blockquote>
<p>ich möchte zum Beispiel aus 0x00 und 0x91 das int 145 bekommen dh Syst= 145<br />
ich bekomme aber -28160.</p>
</blockquote>
<p>Dann hast du auf jeden Fall schonmal die Byte-Order vertauscht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2256747</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2256747</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Wed, 03 Oct 2012 15:47:25 GMT</pubDate></item><item><title><![CDATA[Reply to Aus 2 bytes(char) einen 16 bit oder int machen on Thu, 04 Oct 2012 14:01:17 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Danke für eure Hilfe alle.</p>
<p>hustbaer schrieb:</p>
<blockquote>
<blockquote>
<p>ich möchte zum Beispiel aus 0x00 und 0x91 das int 145 bekommen dh Syst= 145<br />
ich bekomme aber -28160.</p>
</blockquote>
<p>Dann hast du auf jeden Fall schonmal die Byte-Order vertauscht.</p>
</blockquote>
<p>Ja da hattest du recht, Dumm von mir <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> , danke</p>
<p>Ich möchte diese int (Syst) als datagramm über TCP senden, am Empfänger bekomme ich dann aber anstatt z.B 145 der Ascii zeichen <em><strong>‘</strong></em></p>
<pre><code class="language-cpp">struct To_sendTcp {char data[20] ;} To_sendTcp;
//OctetStuffReceiverfunt ist ein char array mit hex Wertes

To_sendTcp.data[0]='D';
To_sendTcp.data[1]='A';
To_sendTcp.data[2]='T';
To_sendTcp.data[3]='A';
To_sendTcp.data[4]='#';
To_sendTcp.data[5]=20;
To_sendTcp.data[6]='0';
memset(To_sendTcp.data+8,'-',1);
To_sendTcp.data[9]=static_cast&lt;int&gt;(OctetStuffReceiverfunt.str[4]);
To_sendTcp.data[10]='-';
To_sendTcp.data[11]=static_cast&lt;int&gt;(OctetStuffReceiverfunt.str[5]);
To_sendTcp.data[12]=' ';
To_sendTcp.data[13]=OctetStuffReceiverfunt.str[6];
To_sendTcp.data[14]=':';
To_sendTcp.data[15]=(int)OctetStuffReceiverfunt.str[7];
To_sendTcp.data[16]='#';
To_sendTcp.data[17]=Syst;
To_sendTcp.data[18]='#';
To_sendTcp.data[19]=(int)OctetStuffReceiverfunt.str[12];
</code></pre>
<p>ich bekomme etwas wie diese <em><strong>DATA#0«-�-Ì Ì:Ì# #Ì</strong></em>.</p>
<p>hat eine von euch eine Ahnung wie ich das eintellen soll ?</p>
<p>Grüß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2257023</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2257023</guid><dc:creator><![CDATA[ryoban]]></dc:creator><pubDate>Thu, 04 Oct 2012 14:01:17 GMT</pubDate></item><item><title><![CDATA[Reply to Aus 2 bytes(char) einen 16 bit oder int machen on Thu, 04 Oct 2012 14:17:14 GMT]]></title><description><![CDATA[<p>ryoban schrieb:</p>
<blockquote>
<p>ich bekomme etwas wie diese <em><strong>DATA#0«-�-Ì Ì:Ì# #Ì</strong></em>.</p>
</blockquote>
<p>Und was hättest du statt dessen gerne?</p>
<p>BTW: OctetStuffReceiverfunt enthält bei dir ganz sicher keine &quot;hex werte&quot;.<br />
Wenn du Hex Werte willst, dann wirst du die selbst basteln müssen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2257033</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2257033</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Thu, 04 Oct 2012 14:17:14 GMT</pubDate></item><item><title><![CDATA[Reply to Aus 2 bytes(char) einen 16 bit oder int machen on Thu, 04 Oct 2012 14:35:48 GMT]]></title><description><![CDATA[<p>hustbaer schrieb:</p>
<blockquote>
<p>Und was hättest du statt dessen gerne?</p>
</blockquote>
<p>ich hätte eher gern so <em><strong>DATA#2003-07-12 14:29#145#62#70</strong></em></p>
<p>die int/dezimal werte sozugen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2257045</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2257045</guid><dc:creator><![CDATA[ryoban]]></dc:creator><pubDate>Thu, 04 Oct 2012 14:35:48 GMT</pubDate></item><item><title><![CDATA[Reply to Aus 2 bytes(char) einen 16 bit oder int machen on Thu, 04 Oct 2012 17:39:44 GMT]]></title><description><![CDATA[<p>Ja sowas hab ich schon vermutet.<br />
Dir ist wohl nicht klar dass char(20) nicht gleich &quot;20&quot; ist.</p>
<p>20 ist ein Byte mit dem Wert 20.<br />
&quot;20&quot; sind zwei Byte mit den Werten '2' und '0'.<br />
Wobei '2' nicht 2 ist und '0' nicht 0.</p>
<p>Guckst du<br />
<a href="http://www.ascii-code.com/" rel="nofollow">http://www.ascii-code.com/</a><br />
<a href="http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/" rel="nofollow">http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/</a><br />
...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2257123</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2257123</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Thu, 04 Oct 2012 17:39:44 GMT</pubDate></item><item><title><![CDATA[Reply to Aus 2 bytes(char) einen 16 bit oder int machen on Thu, 04 Oct 2012 17:57:55 GMT]]></title><description><![CDATA[<p>Noch ein kleiner Tip: ein Zeichen == ein Byte.<br />
&quot;DATA#2003-07-12 14:29#145#62#70&quot; ist 31 Zeichen lang.<br />
<code>char data[20]</code> ist 20 Bytes lang.</p>
<p>Fällt dir was auf?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2257135</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2257135</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Thu, 04 Oct 2012 17:57:55 GMT</pubDate></item><item><title><![CDATA[Reply to Aus 2 bytes(char) einen 16 bit oder int machen on Thu, 04 Oct 2012 18:43:27 GMT]]></title><description><![CDATA[<p>Payload klingt so nach metasploit.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2257144</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2257144</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 04 Oct 2012 18:43:27 GMT</pubDate></item><item><title><![CDATA[Reply to Aus 2 bytes(char) einen 16 bit oder int machen on Thu, 04 Oct 2012 20:08:34 GMT]]></title><description><![CDATA[<p>Wo steht hier was von Payload? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2257171</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2257171</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Thu, 04 Oct 2012 20:08:34 GMT</pubDate></item></channel></rss>