<?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[Ich möchte einen Random Integer Wert in einen String packen...]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>wie schon in der Überschrift.</p>
<p>Ich möchte gerne das random Ergebnis von meinerandomzahl<br />
in den String myausgabe packen.<br />
Leider weiß ich nicht wie...</p>
<p>void funktion()<br />
{<br />
int meinerandomzahl = rand();<br />
std::string myausgabe;</p>
<p>//danach wirds noch komplizierter. Der String soll ein Const String werden.<br />
also wenn ich oben std::string myausgabe=&quot;Test&quot;; schreibe klappts auch.<br />
Nur wie krieg ich den integerwert da rein?</p>
<p>const char* deklarer=myausgabe.c_str();</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/285336/ich-möchte-einen-random-integer-wert-in-einen-string-packen</link><generator>RSS for Node</generator><lastBuildDate>Fri, 21 Aug 2026 09:42:34 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/285336.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 18 Apr 2011 14:46:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Ich möchte einen Random Integer Wert in einen String packen... on Mon, 18 Apr 2011 14:46:27 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>wie schon in der Überschrift.</p>
<p>Ich möchte gerne das random Ergebnis von meinerandomzahl<br />
in den String myausgabe packen.<br />
Leider weiß ich nicht wie...</p>
<p>void funktion()<br />
{<br />
int meinerandomzahl = rand();<br />
std::string myausgabe;</p>
<p>//danach wirds noch komplizierter. Der String soll ein Const String werden.<br />
also wenn ich oben std::string myausgabe=&quot;Test&quot;; schreibe klappts auch.<br />
Nur wie krieg ich den integerwert da rein?</p>
<p>const char* deklarer=myausgabe.c_str();</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2051176</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2051176</guid><dc:creator><![CDATA[RobDust]]></dc:creator><pubDate>Mon, 18 Apr 2011 14:46:27 GMT</pubDate></item><item><title><![CDATA[Reply to Ich möchte einen Random Integer Wert in einen String packen... on Mon, 18 Apr 2011 14:58:32 GMT]]></title><description><![CDATA[<p>In etwa so:</p>
<pre><code class="language-cpp">int myRandomValue = /* ... whatever random value ... */;
std::stringstream str;
str &lt;&lt; myRandomValue;
const std::string myString(str.str());
</code></pre>
<p><a href="http://www.cplusplus.com/reference/iostream/stringstream/" rel="nofollow">stringstream</a><br />
<a href="http://www.c-plusplus.net/forum/39488" rel="nofollow">FAQ hier im Forum</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2051184</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2051184</guid><dc:creator><![CDATA[Tobias Gerg]]></dc:creator><pubDate>Mon, 18 Apr 2011 14:58:32 GMT</pubDate></item><item><title><![CDATA[Reply to Ich möchte einen Random Integer Wert in einen String packen... on Tue, 19 Apr 2011 09:38:34 GMT]]></title><description><![CDATA[<p>Hallo,<br />
stringstream</p>
<p>das tut es <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="🙂"
    /><br />
Musste noch als anfänger bisl suchen.<br />
#include &lt;sstream&gt;</p>
<p>hat geholfen <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>
<p>so läuft es nun:</p>
<p>void funktion()<br />
{<br />
int meinerandomzahl = rand();<br />
ss &lt;&lt; meinerandomzahl;<br />
std::string myausgabe(ss.str());<br />
const char* deklarer=myausgabe.c_str();</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2051531</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2051531</guid><dc:creator><![CDATA[RobDust]]></dc:creator><pubDate>Tue, 19 Apr 2011 09:38:34 GMT</pubDate></item><item><title><![CDATA[Reply to Ich möchte einen Random Integer Wert in einen String packen... on Tue, 19 Apr 2011 09:42:30 GMT]]></title><description><![CDATA[<p>Nutze bitte [cpp]-Tags, um Code zu posten. Und lerne daraus, das nächstemal auch die FAQ zu konsultieren <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/2051532</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2051532</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Tue, 19 Apr 2011 09:42:30 GMT</pubDate></item></channel></rss>