<?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[In String, Variable + Text schreiben]]></title><description><![CDATA[<p>Hey ist es möglich in einem String einen Text + Variable zu speichern?<br />
z.B. so:</p>
<pre><code>string test = &quot;Das Pokemon &quot; &lt;&lt; s_poke &lt;&lt; &quot; wurde soeben auserwaehlt!&quot;;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/324345/in-string-variable-text-schreiben</link><generator>RSS for Node</generator><lastBuildDate>Tue, 14 Jul 2026 14:54:23 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/324345.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 13 Mar 2014 14:00:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to In String, Variable + Text schreiben on Thu, 13 Mar 2014 14:00:43 GMT]]></title><description><![CDATA[<p>Hey ist es möglich in einem String einen Text + Variable zu speichern?<br />
z.B. so:</p>
<pre><code>string test = &quot;Das Pokemon &quot; &lt;&lt; s_poke &lt;&lt; &quot; wurde soeben auserwaehlt!&quot;;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2388684</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2388684</guid><dc:creator><![CDATA[Skeptar.]]></dc:creator><pubDate>Thu, 13 Mar 2014 14:00:43 GMT</pubDate></item><item><title><![CDATA[Reply to In String, Variable + Text schreiben on Thu, 13 Mar 2014 14:03:43 GMT]]></title><description><![CDATA[<p>Schau dir mal <code>std::stringstream</code> an.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2388685</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2388685</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Thu, 13 Mar 2014 14:03:43 GMT</pubDate></item><item><title><![CDATA[Reply to In String, Variable + Text schreiben on Thu, 13 Mar 2014 14:03:56 GMT]]></title><description><![CDATA[<p>ja, mit stringstreams:</p>
<pre><code>#include &lt;sstream&gt;
#include &lt;string&gt;

int main()
{
	std::ostringstream StrStream;
	StrStream &lt;&lt; &quot;Das Pokemon &quot; &lt;&lt; s_poke &lt;&lt; &quot; wurde soeben auserwaehlt!&quot;;
	std::string Test = StrStream.str();
}
</code></pre>
<p><a href="http://en.cppreference.com/w/cpp/io/basic_stringstream" rel="nofollow">http://en.cppreference.com/w/cpp/io/basic_stringstream</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2388686</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2388686</guid><dc:creator><![CDATA[Fytch]]></dc:creator><pubDate>Thu, 13 Mar 2014 14:03:56 GMT</pubDate></item><item><title><![CDATA[Reply to In String, Variable + Text schreiben on Thu, 13 Mar 2014 14:12:46 GMT]]></title><description><![CDATA[<p>Danke für die schnellen Antworten!<br />
Nur meine Frage dazu nun:<br />
Ich wollte mit einem Teamplate eine &quot;Standartausgabe&quot; machen.<br />
Aber dann lohnt sich das mit dem Teamplate nicht mehr wenn ich den</p>
<pre><code>std::stringstream
</code></pre>
<p>benutze oder?</p>
<pre><code>//copyright© 2014  Tryoxie_Dev_Team
#include &lt;sstream&gt;
#include &lt;iostream&gt;
#include &lt;conio.h&gt;
#include &lt;string&gt;

using namespace std;

template&lt;typename T&gt;
void ausgabe(T text){
    cout &lt;&lt; &quot;--------------------------------------------------------------------------------&quot;;
    cout &lt;&lt; text &lt;&lt; &quot;\n&quot;;
    cout &lt;&lt; &quot;--------------------------------------------------------------------------------&quot;;
}

int main(){

cout &lt;&lt; &quot;------------------------\n&quot;;
cout &lt;&lt; &quot;Bitte Pokemon auswaehlen\n&quot;;
cout &lt;&lt; &quot;------------------------\n\n&quot;;

cout &lt;&lt; &quot;1. Shiggy    (Wasser)\n&quot;;
cout &lt;&lt; &quot;2. Bisasam   (Pflanze)\n&quot;;
cout &lt;&lt; &quot;3. Glumanda  (Feuer)\n&quot;;
string s_poke;
cin &gt;&gt; s_poke;

if(s_poke != &quot;Shiggy&quot; &amp;&amp; s_poke != &quot;Bisasam&quot; &amp;&amp; s_poke != &quot;Glumanda&quot;){
    cout &lt;&lt; &quot;Falsche eingabe!&quot;;
}
else{
    ostringstream StrStream;
    StrStream &lt;&lt; &quot;Das Pokemon &quot; &lt;&lt; s_poke &lt;&lt; &quot; wurde soeben auserwaehlt!&quot;;
    string test = StrStream.str();
    ausgabe(test);
}

getch();
return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2388690</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2388690</guid><dc:creator><![CDATA[Skeptar.]]></dc:creator><pubDate>Thu, 13 Mar 2014 14:12:46 GMT</pubDate></item><item><title><![CDATA[Reply to In String, Variable + Text schreiben on Fri, 14 Mar 2014 09:09:04 GMT]]></title><description><![CDATA[<p>Das geht mit einem Manipulator mit Parameter - etwa so:</p>
<pre><code>struct pokemon_auswahl_type
{
    pokemon_auswahl_type( const std::string&amp; text ) : text_( text ) {}
    std::string text_;
};
std::ostream&amp; operator&lt;&lt;( std::ostream&amp; out, const pokemon_auswahl_type&amp; x )
{
    return out &lt;&lt; &quot;Das Pokemon &quot; &lt;&lt; x.text_ &lt;&lt; &quot; wurde soeben auserwaehlt!&quot;;
}

pokemon_auswahl_type pokemon_auswahl( const std::string&amp; s_poke )
{
    return pokemon_auswahl_type( s_poke );
}
</code></pre>
<p>Aufruf:</p>
<pre><code>cout &lt;&lt; pokemon_auswahl(s_poke) &lt;&lt; endl;
</code></pre>
<p>oder auch als Template, wenn s_poke nicht vom Typ <code>std::string</code> ist.</p>
<pre><code>template&lt; typename T &gt;
struct pokemon_auswahl_type
{
    pokemon_auswahl_type( const T&amp; text ) : text_( text ) {}
    T text_; // oder auch const T&amp; text_;
};
template&lt; typename T &gt;
std::ostream&amp; operator&lt;&lt;( std::ostream&amp; out, const pokemon_auswahl_type&lt; T &gt;&amp; x )
{
    return out &lt;&lt; &quot;Das Pokemon &quot; &lt;&lt; x.text_ &lt;&lt; &quot; wurde soeben auserwaehlt!&quot;;
}

template&lt; typename T &gt;
pokemon_auswahl_type&lt; T &gt; pokemon_auswahl(const T&amp; s_poke)
{
    return pokemon_auswahl_type&lt; T &gt;( s_poke );
}
</code></pre>
<p>Der Aufruf bleibt der gleiche.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2388822</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2388822</guid><dc:creator><![CDATA[Werner_logoff]]></dc:creator><pubDate>Fri, 14 Mar 2014 09:09:04 GMT</pubDate></item><item><title><![CDATA[Reply to In String, Variable + Text schreiben on Fri, 14 Mar 2014 11:10:02 GMT]]></title><description><![CDATA[<p>es geht auch sehr einfach:</p>
<p>string mit Text verbinden:</p>
<pre><code>std::string t =&quot;Hallo&quot;;
t += &quot; Welt&quot;;
</code></pre>
<p>oder dein Beispiel:</p>
<pre><code>std::string t = std::string(&quot;TEXT&quot;) + variable + std::string(&quot;TEXT&quot;);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2388852</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2388852</guid><dc:creator><![CDATA[Sepultura]]></dc:creator><pubDate>Fri, 14 Mar 2014 11:10:02 GMT</pubDate></item><item><title><![CDATA[Reply to In String, Variable + Text schreiben on Fri, 14 Mar 2014 11:11:06 GMT]]></title><description><![CDATA[<p>Sepultura schrieb:</p>
<blockquote>
<pre><code>std::string t = std::string(&quot;TEXT&quot;) + variable + std::string(&quot;TEXT&quot;);
</code></pre>
</blockquote>
<p>Das klappt nur mit Strings oder Chars.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2388853</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2388853</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Fri, 14 Mar 2014 11:11:06 GMT</pubDate></item><item><title><![CDATA[Reply to In String, Variable + Text schreiben on Fri, 14 Mar 2014 11:27:58 GMT]]></title><description><![CDATA[<p>Nexus schrieb:</p>
<blockquote>
<p>Sepultura schrieb:</p>
<blockquote>
<pre><code>std::string t = std::string(&quot;TEXT&quot;) + variable + std::string(&quot;TEXT&quot;);
</code></pre>
</blockquote>
<p>Das klappt nur mit Strings oder Chars.</p>
</blockquote>
<p>std::to_string</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2388859</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2388859</guid><dc:creator><![CDATA[nein]]></dc:creator><pubDate>Fri, 14 Mar 2014 11:27:58 GMT</pubDate></item></channel></rss>