<?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[Typ umwandlung]]></title><description><![CDATA[<p>Hi,</p>
<p>ich hab eine Frage.</p>
<p>Und zwar habe ich ein Programm das einen MD5 Hash generiert.</p>
<p>Nun würde ich gerne diesen Hash in einem String weiterverarbeiten. Aber leider weiß ich nicht wie ich den Hash im String speichern kann.</p>
<p>Das Programm sieht bisher so aus:</p>
<pre><code class="language-cpp">unsigned char hashwert1[16];
string text1 = &quot;Hallo&quot;;
        char text2[50];
        strcpy(text2,text1);
md5(text2, hashwert1);
    for(int i = 0; i &lt; 16; i++ )
        printf( &quot;%02x&quot;, hashwert1[i] );
</code></pre>
<p>Hiermit wird mir der mir der MD5-Hash ausgegeben. Allerding möchte ich den nun in einem String speichern.</p>
<p>Wenn ich den Char &quot;hashwert1&quot; einfach einem String zuweise erhalte ich leider nicht den Hashwert sondern nur sehr komische Zeichen. Also müsste ich das noch irgendwie umwandeln denke ich.</p>
<p>MFG</p>
<p>jango</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/194840/typ-umwandlung</link><generator>RSS for Node</generator><lastBuildDate>Tue, 29 Sep 2026 17:00:24 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/194840.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 11 Oct 2007 12:57:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Typ umwandlung on Thu, 11 Oct 2007 12:57:39 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich hab eine Frage.</p>
<p>Und zwar habe ich ein Programm das einen MD5 Hash generiert.</p>
<p>Nun würde ich gerne diesen Hash in einem String weiterverarbeiten. Aber leider weiß ich nicht wie ich den Hash im String speichern kann.</p>
<p>Das Programm sieht bisher so aus:</p>
<pre><code class="language-cpp">unsigned char hashwert1[16];
string text1 = &quot;Hallo&quot;;
        char text2[50];
        strcpy(text2,text1);
md5(text2, hashwert1);
    for(int i = 0; i &lt; 16; i++ )
        printf( &quot;%02x&quot;, hashwert1[i] );
</code></pre>
<p>Hiermit wird mir der mir der MD5-Hash ausgegeben. Allerding möchte ich den nun in einem String speichern.</p>
<p>Wenn ich den Char &quot;hashwert1&quot; einfach einem String zuweise erhalte ich leider nicht den Hashwert sondern nur sehr komische Zeichen. Also müsste ich das noch irgendwie umwandeln denke ich.</p>
<p>MFG</p>
<p>jango</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1382828</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1382828</guid><dc:creator><![CDATA[jango]]></dc:creator><pubDate>Thu, 11 Oct 2007 12:57:39 GMT</pubDate></item><item><title><![CDATA[Reply to Typ umwandlung on Thu, 11 Oct 2007 12:59:25 GMT]]></title><description><![CDATA[<p>strcpy (string, haswert);</p>
<p>oder</p>
<p>sprintf (string, &quot;%s&quot;, hashwert);</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1382830</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1382830</guid><dc:creator><![CDATA[Fake oder Echt]]></dc:creator><pubDate>Thu, 11 Oct 2007 12:59:25 GMT</pubDate></item><item><title><![CDATA[Reply to Typ umwandlung on Thu, 11 Oct 2007 13:01:33 GMT]]></title><description><![CDATA[<p><a href="http://www.cplusplus.com/reference/clibrary/cstdio/sprintf.html" rel="nofollow">http://www.cplusplus.com/reference/clibrary/cstdio/sprintf.html</a> anstatt printf ist wohl am einfachsten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1382832</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1382832</guid><dc:creator><![CDATA[cfbdf]]></dc:creator><pubDate>Thu, 11 Oct 2007 13:01:33 GMT</pubDate></item><item><title><![CDATA[Reply to Typ umwandlung on Thu, 11 Oct 2007 13:06:46 GMT]]></title><description><![CDATA[<p>jango schrieb:</p>
<blockquote>
<p>Wenn ich den Char &quot;hashwert1&quot; einfach einem String zuweise erhalte ich leider nicht den Hashwert sondern nur sehr komische Zeichen. Also müsste ich das noch irgendwie umwandeln denke ich.</p>
</blockquote>
<p>Der Hash-Wert besteht aus nahezu beliebigen Zeichen, und du erhältst ihre jeweilige ASCII-Repräsentation. Das sollte ausreichen, um damit arbeiten zu können.</p>
<p>Wenn du etwas pseudo-lesbares willst, kannst du auch in einer Schleife über das Array rennen und jeden char als Hex-Wert verarbeiten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1382839</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1382839</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Thu, 11 Oct 2007 13:06:46 GMT</pubDate></item><item><title><![CDATA[Reply to Typ umwandlung on Thu, 11 Oct 2007 13:09:09 GMT]]></title><description><![CDATA[<p>Das ist der Fehler den ich erhalte wenn ich es mit sprintf probiere.</p>
<p>error: cannot convert 'std::string' to 'char*' for argument '1' to 'int sprintf(char*, const char*, ...)'</p>
<p>jango</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1382841</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1382841</guid><dc:creator><![CDATA[jango]]></dc:creator><pubDate>Thu, 11 Oct 2007 13:09:09 GMT</pubDate></item><item><title><![CDATA[Reply to Typ umwandlung on Thu, 11 Oct 2007 13:11:54 GMT]]></title><description><![CDATA[<p>Liegt wohl daran, daß strcpy() keine Ahnung von std::string hat - und darum <em>hier</em> auch völliger Käse ist. (*notiert* Tadel an BitWax und cfbdf für sinnlose Kommentare)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1382843</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1382843</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Thu, 11 Oct 2007 13:11:54 GMT</pubDate></item><item><title><![CDATA[Reply to Typ umwandlung on Thu, 11 Oct 2007 13:13:06 GMT]]></title><description><![CDATA[<p>jango schrieb:</p>
<blockquote>
<p>Das ist der Fehler den ich erhalte wenn ich es mit sprintf probiere.</p>
<p>error: cannot convert 'std::string' to 'char*' for argument '1' to 'int sprintf(char*, const char*, ...)'</p>
<p>jango</p>
</blockquote>
<p>Du musst Dich da schon entscheiden: Willst Du mit &quot;C-Strings&quot; (also &quot;char*/char[]&quot;, &quot;NTBS&quot; - Null Terminated Byte Strings, ...) arbeiten oder mit std::string (= StdLib-Klasse zur Darstellung von Zeichenketten).</p>
<p>Für Ersteres nimmt man sprintf/str___() für Zweiteres nicht.<br />
z.B. kannst Du nicht (sicher) mit sprintf() in einen std::string schreiben...</p>
<p>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1382845</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1382845</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Thu, 11 Oct 2007 13:13:06 GMT</pubDate></item><item><title><![CDATA[Reply to Typ umwandlung on Thu, 11 Oct 2007 13:17:45 GMT]]></title><description><![CDATA[<p>Irgendwie versteh ich gar nichts mehr.</p>
<pre><code class="language-cpp">unsigned char hashwert1[16];
string text1 = &quot;Hallo&quot;;
string AUSGABE;
        char text2[50];
        strcpy(text2,text1);
md5(text2, hashwert1);
    for(int i = 0; i &lt; 16; i++ )
        printf( &quot;%02x&quot;, hashwert1[i] );
</code></pre>
<p>Also ich würde gerne den Hashwert der mir in dem Programm auch in der Konsole ausgegeben wird in dem String AUSGABE speichern.</p>
<p>ich habe es mit sprintf probiert aber das klappt nicht.</p>
<p>MFG</p>
<p>jango</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1382847</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1382847</guid><dc:creator><![CDATA[jango]]></dc:creator><pubDate>Thu, 11 Oct 2007 13:17:45 GMT</pubDate></item><item><title><![CDATA[Reply to Typ umwandlung on Thu, 11 Oct 2007 13:22:05 GMT]]></title><description><![CDATA[<p>Stringstreams bieten sich hier an:</p>
<pre><code class="language-cpp">stringstream out;
out&lt;&lt;hex&lt;&lt;setfill('0');
for(i=0;i&lt;16;++i)
  out&lt;&lt;setw(2)&lt;&lt;hashwert1[i];
AUSGABE = out.str();
</code></pre>
<p>(alternativ geht's über ein char-Array und sprintf())</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1382848</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1382848</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Thu, 11 Oct 2007 13:22:05 GMT</pubDate></item><item><title><![CDATA[Reply to Typ umwandlung on Thu, 11 Oct 2007 13:31:17 GMT]]></title><description><![CDATA[<p>Einen Fehler wirst Du noch drin haben (falls das noch Dein Code ist:</p>
<pre><code class="language-cpp">string text1 = &quot;Hallo&quot;;
char text2[50];
// =&gt;
strcpy(text2,text1.c_str()); // str__-Funktionen kennen keine string-Objekte
   // ... deswegen muss man sich vorher einen (char const*) liefern lassen
</code></pre>
<p>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1382857</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1382857</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Thu, 11 Oct 2007 13:31:17 GMT</pubDate></item><item><title><![CDATA[Reply to Typ umwandlung on Thu, 11 Oct 2007 13:50:23 GMT]]></title><description><![CDATA[<p>CStoll schrieb:</p>
<blockquote>
<p>Liegt wohl daran, daß strcpy() keine Ahnung von std::string hat - und darum <em>hier</em> auch völliger Käse ist. (*notiert* Tadel an BitWax und cfbdf für sinnlose Kommentare)</p>
</blockquote>
<p>Kann ich was dafür, wenn er zu dumm ist eine Doku zu lesen. Und er hat ja schon ganz oben char* und string vermischt. <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1382876</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1382876</guid><dc:creator><![CDATA[cfbdf]]></dc:creator><pubDate>Thu, 11 Oct 2007 13:50:23 GMT</pubDate></item><item><title><![CDATA[Reply to Typ umwandlung on Thu, 11 Oct 2007 13:56:03 GMT]]></title><description><![CDATA[<p>cfbdf schrieb:</p>
<blockquote>
<p>CStoll schrieb:</p>
<blockquote>
<p>Liegt wohl daran, daß strcpy() keine Ahnung von std::string hat - und darum <em>hier</em> auch völliger Käse ist. (*notiert* Tadel an BitWax und cfbdf für sinnlose Kommentare)</p>
</blockquote>
<p>Kann ich was dafür, wenn er zu dumm ist eine Doku zu lesen. Und er hat ja schon ganz oben char* und string vermischt. <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>
</blockquote>
<p>Na dann solltest du ihm auch eine funktionierende Lösung anbieten (und gelegentlich muß man doch auf char* zugreifen, weil die verwendeten Funktionen nichts anderes verstehen).</p>
<p>(*notiert* gelbe Karte an cfbdf)</p>
<p>Edit: Und außerdem kämen bei eurer &quot;Lösung&quot; genauso kryptische Zeichenfolgen heraus wie bei jangos Ursprungsprogramm <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/1382882</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1382882</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Thu, 11 Oct 2007 13:56:03 GMT</pubDate></item><item><title><![CDATA[Reply to Typ umwandlung on Thu, 11 Oct 2007 14:04:57 GMT]]></title><description><![CDATA[<p>CStoll schrieb:</p>
<blockquote>
<p>cfbdf schrieb:</p>
<blockquote>
<p>CStoll schrieb:</p>
<blockquote>
<p>Liegt wohl daran, daß strcpy() keine Ahnung von std::string hat - und darum <em>hier</em> auch völliger Käse ist. (*notiert* Tadel an BitWax und cfbdf für sinnlose Kommentare)</p>
</blockquote>
<p>Kann ich was dafür, wenn er zu dumm ist eine Doku zu lesen. Und er hat ja schon ganz oben char* und string vermischt. <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>
</blockquote>
<p>Na dann solltest du ihm auch eine funktionierende Lösung anbieten (und gelegentlich muß man doch auf char* zugreifen, weil die verwendeten Funktionen nichts anderes verstehen).</p>
</blockquote>
<p>Habe ich. Er hätte nur 19 Zeichen an seinem ersten Programm ändern müssen, wenn ich mich nicht verzählt habe.<br />
test:</p>
<pre><code>s
t
e
x
t
2
,
t
e
x
t
1
=
t
e
x
t
2
;
</code></pre>
<p>stimmt</p>
<blockquote>
<p>Edit: Und außerdem kämen bei eurer &quot;Lösung&quot; genauso kryptische Zeichenfolgen heraus wie bei jangos Ursprungsprogramm <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>
</blockquote>
<p>Meine Lösung hat nix mit der falschen von BitWax zu tun. Du musst meine mal einzeln lesen.</p>
<p>(*notiert* Briefmarken für Karten an CStoll kaufen)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1382889</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1382889</guid><dc:creator><![CDATA[cfbdf]]></dc:creator><pubDate>Thu, 11 Oct 2007 14:04:57 GMT</pubDate></item><item><title><![CDATA[Reply to Typ umwandlung on Thu, 11 Oct 2007 14:08:28 GMT]]></title><description><![CDATA[<p>cfbdf schrieb:</p>
<blockquote>
<blockquote>
<p>Edit: Und außerdem kämen bei eurer &quot;Lösung&quot; genauso kryptische Zeichenfolgen heraus wie bei jangos Ursprungsprogramm <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>
</blockquote>
<p>Meine Lösung hat nix mit der falschen von BitWax zu tun. Du musst meine mal einzeln lesen.</p>
</blockquote>
<p>Da wäre es doch gut gewesen, die Antwort etwas umfangreicher zu formulieren <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>
<blockquote>
<p>(*notiert* Briefmarken für Karten an CStoll kaufen)</p>
</blockquote>
<p>Mach nur, was du denkst <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="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1382894</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1382894</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Thu, 11 Oct 2007 14:08:28 GMT</pubDate></item><item><title><![CDATA[Reply to Typ umwandlung on Thu, 11 Oct 2007 14:22:03 GMT]]></title><description><![CDATA[<p>CStoll schrieb:</p>
<blockquote>
<p>cfbdf schrieb:</p>
<blockquote>
<blockquote>
<p>Edit: Und außerdem kämen bei eurer &quot;Lösung&quot; genauso kryptische Zeichenfolgen heraus wie bei jangos Ursprungsprogramm <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>
</blockquote>
<p>Meine Lösung hat nix mit der falschen von BitWax zu tun. Du musst meine mal einzeln lesen.</p>
</blockquote>
<p>Da wäre es doch gut gewesen, die Antwort etwas umfangreicher zu formulieren <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>
</blockquote>
<p>Ein bisschen sollen die Leute schon noch selber denken. Manchmal reicht ja ein Tipp und es muss nicht immer die Gesammtlösung sein. Das BitWax mit seiner falschen Lösung meine ähnliche &quot;zerstört&quot; hat, war halt dumm.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1382904</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1382904</guid><dc:creator><![CDATA[cfbdf]]></dc:creator><pubDate>Thu, 11 Oct 2007 14:22:03 GMT</pubDate></item></channel></rss>