<?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[ein Int in ein Char konvertieren ABER in Binärdarstellung]]></title><description><![CDATA[<p>Also<br />
ich habe ein<br />
Int code = 0b11111</p>
<p>diesen binär code muss ich aber in einem Char haben<br />
also:<br />
char charcode = &quot;111111&quot;</p>
<p>wie bringe ich sowas zu stande? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/328507/ein-int-in-ein-char-konvertieren-aber-in-binärdarstellung</link><generator>RSS for Node</generator><lastBuildDate>Tue, 07 Jul 2026 13:08:11 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/328507.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 13 Oct 2014 14:38:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to ein Int in ein Char konvertieren ABER in Binärdarstellung on Mon, 13 Oct 2014 14:38:30 GMT]]></title><description><![CDATA[<p>Also<br />
ich habe ein<br />
Int code = 0b11111</p>
<p>diesen binär code muss ich aber in einem Char haben<br />
also:<br />
char charcode = &quot;111111&quot;</p>
<p>wie bringe ich sowas zu stande? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2422003</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2422003</guid><dc:creator><![CDATA[mitch_m]]></dc:creator><pubDate>Mon, 13 Oct 2014 14:38:30 GMT</pubDate></item><item><title><![CDATA[Reply to ein Int in ein Char konvertieren ABER in Binärdarstellung on Mon, 13 Oct 2014 14:42:17 GMT]]></title><description><![CDATA[<p>also 0b11111 ist schonmal gar kein gültiges literal. das hast du also schonmal nicht im programmcode.</p>
<p>und wenn du die bitfolge eh zur kompilierzeit kennt, dann schreib doch einfach:</p>
<pre><code>const char* charcode = &quot;111111&quot;;
</code></pre>
<p>wobei mir nicht bewusst wird, wofür man das brauchen sollte. wenn du zur laufzeit einen integer in binärer darstellung in einen string konvertieren willst, dann nutze einfach die bitweise-operatoren und push_back.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2422004</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2422004</guid><dc:creator><![CDATA[hanstroll123]]></dc:creator><pubDate>Mon, 13 Oct 2014 14:42:17 GMT</pubDate></item><item><title><![CDATA[Reply to ein Int in ein Char konvertieren ABER in Binärdarstellung on Mon, 13 Oct 2014 15:05:03 GMT]]></title><description><![CDATA[<blockquote>
<p>also 0b11111 ist schonmal gar kein gültiges literal</p>
</blockquote>
<p>War schon früh eine GCC-Erweiterung. Seit C++14 ist es auch standardisiert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2422011</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2422011</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Mon, 13 Oct 2014 15:05:03 GMT</pubDate></item><item><title><![CDATA[Reply to ein Int in ein Char konvertieren ABER in Binärdarstellung on Thu, 16 Oct 2014 15:48:53 GMT]]></title><description><![CDATA[<pre><code>std::string int_to_bin_string(int val) {
    char buffer[sizeof(int) * 8];
    char* bufferp = buffer;
    while(val &gt; 0) {
        *bufferp = &quot;01&quot;[val &amp; 1];
        val &gt;&gt;= 1;
        ++bufferp;
    }

    if(std::distance(buffer, bufferp) == 0) {
        return &quot;0&quot;;
    }
    std::string result;
    result.reserve(std::distance(buffer, bufferp));
    std::reverse_copy(buffer, bufferp, std::back_inserter(result));
    return result;
}
</code></pre>
<p>So zb</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2422508</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2422508</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Thu, 16 Oct 2014 15:48:53 GMT</pubDate></item></channel></rss>