<?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[Großschreibung für mehrere Variablen?]]></title><description><![CDATA[<p>Hallo,<br />
ich hoffe es kann mir jemand helfen.</p>
<p>Hab zur Großschreibung eines Strings folgenden Code benutzt, es wird aber eine andere Variable (string du) auch großgeschrieben wird, obwohl ich das nicht will.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
using namespace std;

int main() {

    string ich;
    cin &gt;&gt; ich;
    string du = ich;

    strupr( (char*)ich.c_str() );

    cout &lt;&lt; endl &lt;&lt; &quot;Ich: &quot; &lt;&lt; ich;
    cout &lt;&lt; endl &lt;&lt; &quot;Du: &quot; &lt;&lt; du;

    return 0;
}
</code></pre>
<p>Weiß nicht wieso, aber der string du wird auch automatisch GROSS-geschrieben. Ich will den string du aber wie eingegeben belassen, deswegen schreibe ich ja auch &quot;string du = ich;&quot;.</p>
<p>Vielen Dank.<br />
r.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/153684/großschreibung-für-mehrere-variablen</link><generator>RSS for Node</generator><lastBuildDate>Mon, 07 Sep 2026 22:34:09 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/153684.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 19 Jul 2006 16:35:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Großschreibung für mehrere Variablen? on Wed, 19 Jul 2006 16:35:43 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich hoffe es kann mir jemand helfen.</p>
<p>Hab zur Großschreibung eines Strings folgenden Code benutzt, es wird aber eine andere Variable (string du) auch großgeschrieben wird, obwohl ich das nicht will.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
using namespace std;

int main() {

    string ich;
    cin &gt;&gt; ich;
    string du = ich;

    strupr( (char*)ich.c_str() );

    cout &lt;&lt; endl &lt;&lt; &quot;Ich: &quot; &lt;&lt; ich;
    cout &lt;&lt; endl &lt;&lt; &quot;Du: &quot; &lt;&lt; du;

    return 0;
}
</code></pre>
<p>Weiß nicht wieso, aber der string du wird auch automatisch GROSS-geschrieben. Ich will den string du aber wie eingegeben belassen, deswegen schreibe ich ja auch &quot;string du = ich;&quot;.</p>
<p>Vielen Dank.<br />
r.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1100532</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1100532</guid><dc:creator><![CDATA[composed04]]></dc:creator><pubDate>Wed, 19 Jul 2006 16:35:43 GMT</pubDate></item><item><title><![CDATA[Reply to Großschreibung für mehrere Variablen? on Wed, 19 Jul 2006 18:15:11 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>du hast da durch Vermischung von C und C++ undefiniertes Verhalten verursacht, wodurch es zu dieser Ausgabe kommt. Und zwar hast du zwei std::string. Durch das zuwesien von ich auf du wird durch das intelligente Kopierverhalten deiner Implementation intern nur ein Pointer von dem internen char-Pointer kopiert, <em>nicht</em> aber der Inhalt ansich.<br />
Da du aber dann einen C-Style Cast einsetzt, um den <em>eigentlich konstanten</em> C-String zu ändern, wird dadurch der Inhalt beider string-Instanzen geändert.</p>
<p>Benutzte deshalb in C++ immer die C++ casts. Damit wird dir gesagt das deine Umdandlung nicht erlaubt ist (es sei denn du setzt const-cast ein).</p>
<p>Die Lösung ist, das du dich nach <em>toupper</em> umschaust.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1100534</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1100534</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Wed, 19 Jul 2006 18:15:11 GMT</pubDate></item><item><title><![CDATA[Reply to Großschreibung für mehrere Variablen? on Thu, 20 Jul 2006 10:40:28 GMT]]></title><description><![CDATA[<p>composed04 schrieb:</p>
<blockquote>
<p>strupr( (char*)ich.c_str() );</p>
</blockquote>
<p>Undefiniertes Verhalten. c_str gibt nicht umsonst einen Zeiger auf const charT zurück. Was lässt dich eigentlich glauben, du darfst hier einfach das const wegcasten?</p>
<blockquote>
<p>The program shall not alter any of the values stored in the array. Nor shall the program treat the returned value as a valid pointer value after any subsequent call to a non-const member function of the class basic_string that designates the same object as this.</p>
</blockquote>
<p>Generell sind C-String Funktionen und std::string keine gute Mischung.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1100987</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1100987</guid><dc:creator><![CDATA[groovemaster]]></dc:creator><pubDate>Thu, 20 Jul 2006 10:40:28 GMT</pubDate></item><item><title><![CDATA[Reply to Großschreibung für mehrere Variablen? on Thu, 20 Jul 2006 11:18:39 GMT]]></title><description><![CDATA[<p>Umwandlung in Großbuchstaben:</p>
<pre><code class="language-cpp">std::transform(ich.begin(), ich.end(), ich.begin(), _totupper);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1101048</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1101048</guid><dc:creator><![CDATA[pZy]]></dc:creator><pubDate>Thu, 20 Jul 2006 11:18:39 GMT</pubDate></item><item><title><![CDATA[Reply to Großschreibung für mehrere Variablen? on Thu, 20 Jul 2006 11:28:33 GMT]]></title><description><![CDATA[<p>pZy schrieb:</p>
<blockquote>
<p>Umwandlung in Großbuchstaben:</p>
<pre><code class="language-cpp">std::transform(ich.begin(), ich.end(), ich.begin(), _totupper);
</code></pre>
</blockquote>
<p>ach was</p>
<pre><code class="language-cpp">std::transform(ich.begin(), ich.end(), ich.begin(), std::bind2nd(std::toupper&lt;char&gt;, std::locale()) );
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1101063</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1101063</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Thu, 20 Jul 2006 11:28:33 GMT</pubDate></item><item><title><![CDATA[Reply to Großschreibung für mehrere Variablen? on Thu, 20 Jul 2006 11:43:41 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">use_facet&lt;ctype&lt;string::value_type&gt; &gt;(locale()).toupper(ich.begin(), ich.end());
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1101088</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1101088</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Thu, 20 Jul 2006 11:43:41 GMT</pubDate></item><item><title><![CDATA[Reply to Großschreibung für mehrere Variablen? on Thu, 20 Jul 2006 14:27:54 GMT]]></title><description><![CDATA[<p>Danke,<br />
eure Antworten waren sehr hilfreich.</p>
<p>r.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1101296</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1101296</guid><dc:creator><![CDATA[composed04]]></dc:creator><pubDate>Thu, 20 Jul 2006 14:27:54 GMT</pubDate></item><item><title><![CDATA[Reply to Großschreibung für mehrere Variablen? on Thu, 20 Jul 2006 16:57:29 GMT]]></title><description><![CDATA[<p>Braunstein schrieb:</p>
<blockquote>
<pre><code class="language-cpp">use_facet&lt;ctype&lt;string::value_type&gt; &gt;(locale()).toupper(ich.begin(), ich.end());
</code></pre>
</blockquote>
<p>schön wärs. dieser toupper-overload arbeitet mit pointern und nicht iteratoren. damit wird das ganze unportabel.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1101390</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1101390</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Thu, 20 Jul 2006 16:57:29 GMT</pubDate></item><item><title><![CDATA[Reply to Großschreibung für mehrere Variablen? on Thu, 20 Jul 2006 18:42:17 GMT]]></title><description><![CDATA[<p>composed04 schrieb:</p>
<blockquote>
<p>Hab zur Großschreibung eines Strings folgenden Code benutzt, es wird aber eine andere Variable (string du) auch großgeschrieben wird, obwohl ich das nicht will.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
using namespace std;

int main() {
    
    string ich;
    cin &gt;&gt; ich;
    string du = ich;

    strupr( (char*)ich.c_str() );

    cout &lt;&lt; endl &lt;&lt; &quot;Ich: &quot; &lt;&lt; ich;
    cout &lt;&lt; endl &lt;&lt; &quot;Du: &quot; &lt;&lt; du;

    return 0;
}
</code></pre>
<p>r.</p>
</blockquote>
<p>@compose04 mit welchem Compiler hast du das beschriebene Fehlverhalten erzeugt?</p>
<p>Ich war über diverse Aussagen hier etwas kritisch und hab den Code mit VC++ 2005 und gcc-3.4.4 getestet. Beide Compiler produzieren nicht den Fehler, den Du beschreibst!</p>
<p>VS2005 warning C4996: 'strupr' wurde als veraltet deklariert</p>
<p>Ausgabe jeweils:</p>
<p>Ich: ICH<br />
Du: ich</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1101443</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1101443</guid><dc:creator><![CDATA[Helmut S.]]></dc:creator><pubDate>Thu, 20 Jul 2006 18:42:17 GMT</pubDate></item><item><title><![CDATA[Reply to Großschreibung für mehrere Variablen? on Thu, 20 Jul 2006 18:47:36 GMT]]></title><description><![CDATA[<p>Es ist implementierungsabhängig, deshalb hast du ein anderes Ergebnis. Normalerweise kenne ich es so, das std::string ein Copy-on-Write (bzw. Copy-on-Modify) Verhalten hat (wie es beim ersten Posting der Fall ist). Da dieses Speicherschonender ist. Aber wenn der Implementierer von std::string es anders sieht, kann es das Verhalten vom VC++8.0 sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1101446</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1101446</guid><dc:creator><![CDATA[Artchi]]></dc:creator><pubDate>Thu, 20 Jul 2006 18:47:36 GMT</pubDate></item><item><title><![CDATA[Reply to Großschreibung für mehrere Variablen? on Thu, 20 Jul 2006 18:50:42 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/527">@Helmut</a> S. : es kann schon sein, das bei deinem Compiler bzw. bei deiner STL-Implementation der Wert des string wirklich kopiert wird, und nicht nur ein Zeiger übernommen wird. Das spielt aber keine Rolle, denn durch den cast wird der Standard verletzt und damit undefiniertes Verhalten erzeugt. Davon ist dringenst abzuraten. Denn auf andern Implementation kann alles mögliche passieren.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1101447</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1101447</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Thu, 20 Jul 2006 18:50:42 GMT</pubDate></item><item><title><![CDATA[Reply to Großschreibung für mehrere Variablen? on Thu, 20 Jul 2006 19:26:47 GMT]]></title><description><![CDATA[<p>es gibt auch andere möglichkeiten. es könnte sich z.b. um eine string-implementation handeln, die den string selbst nicht als array speichert und das ergebnis von c_str erst beim aufruf erzeugt (dann gibt es irgendwo wohl auch noch einen garbage collector). auch in diesem falle würde das verändern von c_str nicht das gewünschte ergebnis haben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1101462</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1101462</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Thu, 20 Jul 2006 19:26:47 GMT</pubDate></item><item><title><![CDATA[Reply to Großschreibung für mehrere Variablen? on Thu, 20 Jul 2006 21:56:32 GMT]]></title><description><![CDATA[<p>*falscher Thread*</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1101510</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1101510</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Thu, 20 Jul 2006 21:56:32 GMT</pubDate></item><item><title><![CDATA[Reply to Großschreibung für mehrere Variablen? on Tue, 25 Jul 2006 20:01:43 GMT]]></title><description><![CDATA[<p>hab den Borland C++ Compiler 5.5 benutzt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1104157</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1104157</guid><dc:creator><![CDATA[composed04]]></dc:creator><pubDate>Tue, 25 Jul 2006 20:01:43 GMT</pubDate></item></channel></rss>