<?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[Wie funktioniert der Vergleich bei String-Array mit einzelnen Zeichen]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe eine Frage.<br />
Wenn ich einen String definiere, wie kann ich dann vergleichen, ob zum Beispiel das 3te Zeichen des Strings ein bestimmtes Zeichen ist?</p>
<p>Beispiel was aber nicht funktioniert:</p>
<pre><code>...
string s = &quot;Fußball&quot;;
if(s[2] == ß) s.replace(2,1,&quot;ss&quot;);
...
</code></pre>
<p>Die Frage ist hier, wie kann ich s[2] und ß miteinander vergleichen?</p>
<p>Vielen Dank und gute Nacht</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/147444/wie-funktioniert-der-vergleich-bei-string-array-mit-einzelnen-zeichen</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Sep 2026 05:39:38 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/147444.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 16 May 2006 23:23:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Wie funktioniert der Vergleich bei String-Array mit einzelnen Zeichen on Tue, 16 May 2006 23:23:37 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe eine Frage.<br />
Wenn ich einen String definiere, wie kann ich dann vergleichen, ob zum Beispiel das 3te Zeichen des Strings ein bestimmtes Zeichen ist?</p>
<p>Beispiel was aber nicht funktioniert:</p>
<pre><code>...
string s = &quot;Fußball&quot;;
if(s[2] == ß) s.replace(2,1,&quot;ss&quot;);
...
</code></pre>
<p>Die Frage ist hier, wie kann ich s[2] und ß miteinander vergleichen?</p>
<p>Vielen Dank und gute Nacht</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1059208</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059208</guid><dc:creator><![CDATA[HariboLight]]></dc:creator><pubDate>Tue, 16 May 2006 23:23:37 GMT</pubDate></item><item><title><![CDATA[Reply to Wie funktioniert der Vergleich bei String-Array mit einzelnen Zeichen on Wed, 17 May 2006 01:42:42 GMT]]></title><description><![CDATA[<p>Versuch es mal mit</p>
<pre><code class="language-cpp">...
if(s[2] == 'ß')
...
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1059216</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059216</guid><dc:creator><![CDATA[SomeBody]]></dc:creator><pubDate>Wed, 17 May 2006 01:42:42 GMT</pubDate></item><item><title><![CDATA[Reply to Wie funktioniert der Vergleich bei String-Array mit einzelnen Zeichen on Wed, 17 May 2006 06:45:19 GMT]]></title><description><![CDATA[<p>Ne, das funktiniert leider auch nicht, bekomme dann folgende Warnung:</p>
<p>Multiple Markers at thie line<br />
- mulit-character character constant<br />
- comparison is always false due to limited range of data type</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1059270</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059270</guid><dc:creator><![CDATA[HariboLight]]></dc:creator><pubDate>Wed, 17 May 2006 06:45:19 GMT</pubDate></item><item><title><![CDATA[Reply to Wie funktioniert der Vergleich bei String-Array mit einzelnen Zeichen on Wed, 17 May 2006 06:50:19 GMT]]></title><description><![CDATA[<p>Also 'ß' sollte eigentlich keine derartige Warnung hervorrufen - zeig doch mal deinen genauen Quellcode.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1059274</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059274</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 17 May 2006 06:50:19 GMT</pubDate></item><item><title><![CDATA[Reply to Wie funktioniert der Vergleich bei String-Array mit einzelnen Zeichen on Wed, 17 May 2006 06:56:38 GMT]]></title><description><![CDATA[<p>Da Programm öffnet eine Textdatei und soll in dieser Umlaute und das 'ß' ersetzen.</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;

using namespace std;

int main (int argc, char *argv[])
{	    
    ifstream source(&quot;Test.txt&quot;);
    string command, pattern = &quot;ÄÖÜäöüß&quot;;
    int pos;

    while(getline(source2,command))
    {
    	pos = command.find_first_of(pattern);
    	while(pos &gt; -1)    	
    	{    		
    		if(command[pos] == 'ß') command.replace(pos,1,&quot;ss&quot;); 
    		else if(command[pos] == 'Ä') command.replace(pos,1,&quot;Ae&quot;);
    		else if(command[pos] == 'Ö') command.replace(pos,1,&quot;Oe&quot;);
    		else if(command[pos] == 'Ü') command.replace(pos,1,&quot;Ue&quot;);
    		else if(command[pos] == 'ä') command.replace(pos,1,&quot;ae&quot;);
    		else if(command[pos] == 'ö') command.replace(pos,1,&quot;oe&quot;);
    		else if(command[pos] == 'ü') command.replace(pos,1,&quot;ue&quot;);

    		pos = command.find_first_of(pattern);
    	}
    }

    source.close();
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1059277</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059277</guid><dc:creator><![CDATA[HariboLight]]></dc:creator><pubDate>Wed, 17 May 2006 06:56:38 GMT</pubDate></item><item><title><![CDATA[Reply to Wie funktioniert der Vergleich bei String-Array mit einzelnen Zeichen on Wed, 17 May 2006 07:03:22 GMT]]></title><description><![CDATA[<p>Erstmal solltest du statt &quot;int pos&quot; lieber &quot;size_t pos&quot; verwenden und mit string::npos vergleichen.</p>
<p>Zweitens: In welcher Zeile tritte denn der Fehler auf?</p>
<p>Drittens: Du öffnest die Datei als &quot;source&quot; und liest dann aus &quot;source2&quot; - das sollte bereit ein Fehler gemeldet werden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1059280</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059280</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 17 May 2006 07:03:22 GMT</pubDate></item><item><title><![CDATA[Reply to Wie funktioniert der Vergleich bei String-Array mit einzelnen Zeichen on Wed, 17 May 2006 07:04:28 GMT]]></title><description><![CDATA[<p>Bei getline in der while-Schleife heißt es natürlich auch source, nicht source2.</p>
<p>Die Warnings treten bei allen if bzw. else if-Anweisungen in der while-Schleife auf.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1059281</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059281</guid><dc:creator><![CDATA[HariboLight]]></dc:creator><pubDate>Wed, 17 May 2006 07:04:28 GMT</pubDate></item><item><title><![CDATA[Reply to Wie funktioniert der Vergleich bei String-Array mit einzelnen Zeichen on Wed, 17 May 2006 07:32:31 GMT]]></title><description><![CDATA[<p>Was ist denn size_t pos anders/besser als an int pos?<br />
Und was hat es mit dem string::npos auf sich?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1059297</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059297</guid><dc:creator><![CDATA[HariboLight]]></dc:creator><pubDate>Wed, 17 May 2006 07:32:31 GMT</pubDate></item><item><title><![CDATA[Reply to Wie funktioniert der Vergleich bei String-Array mit einzelnen Zeichen on Wed, 17 May 2006 07:40:41 GMT]]></title><description><![CDATA[<p>HariboLight schrieb:</p>
<blockquote>
<p>Was ist denn size_t pos anders/besser als an int pos?</p>
</blockquote>
<p>&quot;size_t&quot; ist der Datentyp, den die Suchmethoden des Strings zurückgeben. (ist normalerweise ein ausreichend großer <em>unsigned</em> Typ)</p>
<blockquote>
<p>Und was hat es mit dem string::npos auf sich?</p>
</blockquote>
<p>string::find() und Kollegen liefern genau diesen Wert zurück, wenn sie nichts gefunden haben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1059302</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059302</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 17 May 2006 07:40:41 GMT</pubDate></item><item><title><![CDATA[Reply to Wie funktioniert der Vergleich bei String-Array mit einzelnen Zeichen on Wed, 17 May 2006 07:40:57 GMT]]></title><description><![CDATA[<p>Blöde Vermutung: Dein Editor ist im UNICODE-Modus und Umlaute werden deshalb als zwei Bytes gespeichert. 'xx' ist aber ungültig da zwischen '' nur ein Byte stehen darf. Multibyte-Characterkonstanten werden mit L'' ausgedrückt, das würde aber vermutlich nicht tun was Du willst, da die Konsole nicht mit UNICODE arbeiten dürfte.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1059303</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059303</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Wed, 17 May 2006 07:40:57 GMT</pubDate></item><item><title><![CDATA[Reply to Wie funktioniert der Vergleich bei String-Array mit einzelnen Zeichen on Wed, 17 May 2006 07:56:12 GMT]]></title><description><![CDATA[<blockquote>
<p>Blöde Vermutung: Dein Editor ist im UNICODE-Modus und Umlaute werden deshalb als zwei Bytes gespeichert. 'xx' ist aber ungültig da zwischen '' nur ein Byte stehen darf. Multibyte-Characterkonstanten werden mit L'' ausgedrückt, das würde aber vermutlich nicht tun was Du willst, da die Konsole nicht mit UNICODE arbeiten dürfte.</p>
</blockquote>
<p>Genau so ist es, mein Editor ist auf Unicode eingestellt, aber dennoch muss es doch eine Möglichkeit geben innerhalb eines Strings nach bestimmten Zeichen zu suchen und diese dann ersetzen zu können. Soweit ich weiss ist mein ganzes System auf Unicode eingestellt, dass sollte doch dann auch dazu führen, dass es in der Konsole funktioniert.</p>
<p>Das ist doch dann alles Mist.<br />
Das hieße ja, dass mein Programm eventuell läuft, wenn das System mit Unicode arbeitet, aber nicht mehr vernünftig läuft, wenn das System mit ISO arbeitet?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1059307</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059307</guid><dc:creator><![CDATA[HariboLight]]></dc:creator><pubDate>Wed, 17 May 2006 07:56:12 GMT</pubDate></item><item><title><![CDATA[Reply to Wie funktioniert der Vergleich bei String-Array mit einzelnen Zeichen on Wed, 17 May 2006 08:07:33 GMT]]></title><description><![CDATA[<p>Nein, das heißt nur, daß dein Editor 'ß' und dergleichen nicht als char-Werte anerkennt - zur Not könntest du ja deren ASCII-Werte manuell raussuchen und die Escape-Sequenzen '\x..' verwenden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1059313</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059313</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 17 May 2006 08:07:33 GMT</pubDate></item><item><title><![CDATA[Reply to Wie funktioniert der Vergleich bei String-Array mit einzelnen Zeichen on Wed, 17 May 2006 08:14:58 GMT]]></title><description><![CDATA[<p>Als dann quasi per:</p>
<p>if(command[pos] == '\xx..') command.replace(pos,1,&quot;ss&quot;);</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1059316</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059316</guid><dc:creator><![CDATA[HariboLight]]></dc:creator><pubDate>Wed, 17 May 2006 08:14:58 GMT</pubDate></item><item><title><![CDATA[Reply to Wie funktioniert der Vergleich bei String-Array mit einzelnen Zeichen on Wed, 17 May 2006 08:28:12 GMT]]></title><description><![CDATA[<p>Ja, jetzt mußt du nur noch die richtigen Werte dort einsetzen (z.B. ß ist \xE1').</p>
<p>(beachte auch, daß die DOS-Konsole einen anderen Zeichensatz verwendet als Windows-Programme)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1059325</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059325</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 17 May 2006 08:28:12 GMT</pubDate></item><item><title><![CDATA[Reply to Wie funktioniert der Vergleich bei String-Array mit einzelnen Zeichen on Wed, 17 May 2006 08:31:51 GMT]]></title><description><![CDATA[<p>Sind die Escape-Sequenzen plattformunabhängig?<br />
Ich nutze Suse Linux.</p>
<p>Wo guckst du die Sequenzen nach?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1059328</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059328</guid><dc:creator><![CDATA[HariboLight]]></dc:creator><pubDate>Wed, 17 May 2006 08:31:51 GMT</pubDate></item><item><title><![CDATA[Reply to Wie funktioniert der Vergleich bei String-Array mit einzelnen Zeichen on Wed, 17 May 2006 08:42:31 GMT]]></title><description><![CDATA[<p>HariboLight schrieb:</p>
<blockquote>
<p>Sind die Escape-Sequenzen plattformunabhängig?<br />
Ich nutze Suse Linux.</p>
</blockquote>
<p>Alles bis einschließlich \x7F dürfte überall gleich sein, darüber unterscheiden sich die verschiedenen Zeichensätze je nach System.</p>
<blockquote>
<p>Wo guckst du die Sequenzen nach?</p>
</blockquote>
<p>Windows Zeichentabelle.</p>
<p>Um ganz sicher zu sein, daß du die richtigen Werte verwendest, kannst du dir ja eine ASCII-Tabelle ausgeben lassen:</p>
<pre><code class="language-cpp">cout&lt;&lt;hex;
for(int i=1;i&lt;256;++i)
  cout&lt;&lt;&quot;'\\x&quot;&lt;&lt;i&lt;&lt;&quot; = &quot;&lt;&lt;(char)i&lt;&lt;&quot;\n&quot;;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1059334</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059334</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 17 May 2006 08:42:31 GMT</pubDate></item><item><title><![CDATA[Reply to Wie funktioniert der Vergleich bei String-Array mit einzelnen Zeichen on Wed, 17 May 2006 08:47:43 GMT]]></title><description><![CDATA[<p>Danke, aber leider scheint das nicht zu funktionieren.<br />
Die Ausgabe beinhaltet nur die &quot;normalen Zeichen&quot; und sieht exakt wie folgt aus:</p>
<p>'\x1 =<br />
'\x2 =<br />
'\x3 =<br />
'\x4 =<br />
'\x5 =<br />
'\x6 =<br />
'\x7 =<br />
'\x8 =<br />
'\x9 =<br />
'\xa =</p>
<p>'\xb =</p>
<p>'\xc =</p>
<p>'\xd =<br />
'\xe =<br />
'\xf =<br />
'\x10 =<br />
'\x11 =<br />
'\x12 =<br />
'\x13 =<br />
'\x14 =<br />
'\x15 =<br />
'\x16 =<br />
'\x17 =<br />
'\x18 = ▒<br />
'\x19 =<br />
'\x1a = ▒<br />
'\x1b =<br />
\x1c =<br />
'\x1d =<br />
'\x1e =<br />
'\x1f =<br />
'\x20 =<br />
'\x21 = !<br />
'\x22 = &quot;<br />
'\x23 = #<br />
'\x24 = $<br />
'\x25 = %<br />
'\x26 = &amp;<br />
'\x27 = '<br />
'\x28 = (<br />
'\x29 = )<br />
'\x2a = *<br />
'\x2b = +<br />
'\x2c = ,<br />
'\x2d = -<br />
'\x2e = .<br />
'\x2f = /<br />
'\x30 = 0<br />
'\x31 = 1<br />
'\x32 = 2<br />
'\x33 = 3<br />
'\x34 = 4<br />
'\x35 = 5<br />
'\x36 = 6<br />
'\x37 = 7<br />
'\x38 = 8<br />
'\x39 = 9<br />
'\x3a = :<br />
'\x3b = ;<br />
'\x3c = &lt;<br />
'\x3d = =<br />
'\x3e = &gt;<br />
'\x3f = ?<br />
'\x40 = @<br />
'\x41 = A<br />
'\x42 = B<br />
'\x43 = C<br />
'\x44 = D<br />
'\x45 = E<br />
'\x46 = F<br />
'\x47 = G<br />
'\x48 = H<br />
'\x49 = I<br />
'\x4a = J<br />
'\x4b = K<br />
'\x4c = L<br />
'\x4d = M<br />
'\x4e = N<br />
'\x4f = O<br />
'\x50 = P<br />
'\x51 = Q<br />
'\x52 = R<br />
'\x53 = S<br />
'\x54 = T<br />
'\x55 = U<br />
'\x56 = V<br />
'\x57 = W<br />
'\x58 = X<br />
'\x59 = Y<br />
'\x5a = Z<br />
'\x5b = [<br />
'\x5c = \<br />
'\x5d = ]<br />
'\x5e = ^<br />
'\x5f = _<br />
'\x60 = `<br />
'\x61 = a<br />
'\x62 = b<br />
'\x63 = c<br />
'\x64 = d<br />
'\x65 = e<br />
'\x66 = f<br />
'\x67 = g<br />
'\x68 = h<br />
'\x69 = i<br />
'\x6a = j<br />
'\x6b = k<br />
'\x6c = l<br />
'\x6d = m<br />
'\x6e = n<br />
'\x6f = o<br />
'\x70 = p<br />
'\x71 = q<br />
'\x72 = r<br />
'\x73 = s<br />
'\x74 = t<br />
'\x75 = u<br />
'\x76 = v<br />
'\x77 = w<br />
'\x78 = x<br />
'\x79 = y<br />
'\x7a = z<br />
'\x7b = {<br />
'\x7c = |<br />
'\x7d = }<br />
'\x7e = ~<br />
'\x7f =<br />
'\x80 =<br />
'\x81 =<br />
'\x82 =<br />
'\x83 =<br />
'\x84 =<br />
'\x85 =<br />
'\x86 =<br />
'\x87 =<br />
'\x88 =<br />
'\x89 =<br />
'\x8a =<br />
'\x8b =<br />
'\x8c =<br />
'\x8d =<br />
'\x8e =<br />
'\x8f =<br />
'\x90 =<br />
'\x91 =<br />
'\x92 =<br />
'\x93 =<br />
'\x94 =<br />
'\x95 =<br />
'\x96 =<br />
'\x97 =<br />
'\x98 =<br />
'\x99 =<br />
'\x9a =<br />
'\x9b =<br />
'\x9c =<br />
'\x9d =<br />
'\x9e =<br />
'\x9f =<br />
'\xa0 =<br />
'\xa1 =<br />
'\xa2 =<br />
'\xa3 =<br />
'\xa4 =<br />
'\xa5 =<br />
'\xa6 =<br />
'\xa7 =<br />
'\xa8 =<br />
'\xa9 =<br />
'\xaa =<br />
'\xab =<br />
'\xac =<br />
'\xad =<br />
'\xae =<br />
'\xaf =<br />
'\xb0 =<br />
'\xb1 =<br />
'\xb2 =<br />
'\xb3 =<br />
'\xb4 =<br />
'\xb5 =<br />
'\xb6 =<br />
'\xb7 =<br />
'\xb8 =<br />
'\xb9 =<br />
'\xba =<br />
'\xbb =<br />
'\xbc =<br />
'\xbd =<br />
'\xbe =<br />
'\xbf =<br />
'\xc0 =<br />
'\xc1 =<br />
'\xc2 =<br />
'\xc3 =<br />
'\xc4 =<br />
'\xc5 =<br />
'\xc6 =<br />
'\xc7 =<br />
'\xc8 =<br />
'\xc9 =<br />
'\xca =<br />
'\xcb =<br />
'\xcc =<br />
'\xcd =<br />
'\xce =<br />
'\xcf =<br />
'\xd0 =<br />
'\xd1 =<br />
'\xd2 =<br />
'\xd3 =<br />
'\xd4 =<br />
'\xd5 =<br />
'\xd6 =<br />
'\xd7 =<br />
'\xd8 =<br />
'\xd9 =<br />
'\xda =<br />
'\xdb =<br />
'\xdc =<br />
'\xdd =<br />
'\xde =<br />
'\xdf =<br />
'\xe0 =<br />
'\xe1 =<br />
'\xe2 =<br />
'\xe3 =<br />
'\xe4 =<br />
'\xe5 =<br />
'\xe6 =<br />
'\xe7 =<br />
'\xe8 =<br />
'\xe9 =<br />
'\xea =<br />
'\xeb =<br />
'\xec =<br />
'\xed =<br />
'\xee =<br />
'\xef =<br />
'\xf0 =<br />
'\xf1 =<br />
'\xf2 =<br />
'\xf3 =<br />
'\xf4 =<br />
'\xf5 =<br />
'\xf6 =<br />
'\xf7 =<br />
'\xf8 =<br />
'\xf9 =<br />
'\xfa =<br />
'\xfb =<br />
'\xfc =<br />
'\xfd =<br />
'\xfe =<br />
'\xff =</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1059341</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1059341</guid><dc:creator><![CDATA[HariboLight]]></dc:creator><pubDate>Wed, 17 May 2006 08:47:43 GMT</pubDate></item></channel></rss>