<?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[Substring in Schleife]]></title><description><![CDATA[<p>Hallo Leutz, hab ein Problem...<br />
ich will, dass ein String, dessen Länge unbekannt ist, in 3er Substrings eingeteilt wird und diese dann erneut einzeln überprüft werden. Ungefähr so:<br />
↓</p>
<pre><code>string test;
for(int i=0;i&lt;test.length();i=i+3) {
//hier sollen die einzelnen strings definiert werden, 
z.b. mit tri&quot;i&quot;(damit anstelle von &quot;i&quot; eine zahl steht)//
=test.substr(i,3); }
</code></pre>
<p>danke, euer Dieder</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/172672/substring-in-schleife</link><generator>RSS for Node</generator><lastBuildDate>Fri, 18 Sep 2026 00:21:47 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/172672.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 07 Feb 2007 12:58:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Substring in Schleife on Wed, 07 Feb 2007 12:58:00 GMT]]></title><description><![CDATA[<p>Hallo Leutz, hab ein Problem...<br />
ich will, dass ein String, dessen Länge unbekannt ist, in 3er Substrings eingeteilt wird und diese dann erneut einzeln überprüft werden. Ungefähr so:<br />
↓</p>
<pre><code>string test;
for(int i=0;i&lt;test.length();i=i+3) {
//hier sollen die einzelnen strings definiert werden, 
z.b. mit tri&quot;i&quot;(damit anstelle von &quot;i&quot; eine zahl steht)//
=test.substr(i,3); }
</code></pre>
<p>danke, euer Dieder</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1224408</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1224408</guid><dc:creator><![CDATA[Dieder]]></dc:creator><pubDate>Wed, 07 Feb 2007 12:58:00 GMT</pubDate></item><item><title><![CDATA[Reply to Substring in Schleife on Wed, 07 Feb 2007 13:00:49 GMT]]></title><description><![CDATA[<p>Variablennamen kannst du nicht zur Laufzeit zusammensetzen (schon weil die Variablen zur Laufzeit keinen Namen mehr haben). Aber du kannst mehrere gleichartige Werte in ein Array oder vector packen:</p>
<pre><code class="language-cpp">string test;
vector&lt;string&gt; tri;
for(int i=0;i&lt;test.length();i=i+3)
{
  tri.push_back(test.substr(i,3));
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1224410</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1224410</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 07 Feb 2007 13:00:49 GMT</pubDate></item><item><title><![CDATA[Reply to Substring in Schleife on Wed, 07 Feb 2007 13:21:23 GMT]]></title><description><![CDATA[<p>Hey, danke für die schnelle Antwort aber mir ist nicht ganz klar, wie ich diese einzelnen Abschnitte überprüfen könnte? Sagen wir:</p>
<pre><code>for(int i = 0;i &lt; amino.length();i=i+3)
   {
           if (tri.substr(i,3) == &quot;ABC&quot;) {
               tri.substr(i,3) = &quot;Alphabet&quot;;}
           if (tri.substr(i,3) == &quot;DEF&quot;) {
               tri.substr(i,3) = &quot;andere Buchstaben&quot;;}
           //usw

   }
</code></pre>
<p>danke im voraus, Dieder</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1224424</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1224424</guid><dc:creator><![CDATA[Dieder]]></dc:creator><pubDate>Wed, 07 Feb 2007 13:21:23 GMT</pubDate></item><item><title><![CDATA[Reply to Substring in Schleife on Wed, 07 Feb 2007 13:24:34 GMT]]></title><description><![CDATA[<p>In &quot;tri&quot; stehen die einzelnen Teile in einer Array-ähnlichen Struktur drin, d.h. du kannst sie über ihren Index ansprechen:</p>
<pre><code class="language-cpp">for(i=0;i&lt;tri.size();++i)
{
  if(tri[i] == &quot;ABC&quot;)
    tri[i] = &quot;Alphabet&quot;;
  else if(tri[i] == &quot;DEF&quot;)
    tri[i] = &quot;andere Buchstaben&quot;;
  ...
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1224426</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1224426</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 07 Feb 2007 13:24:34 GMT</pubDate></item><item><title><![CDATA[Reply to Substring in Schleife on Wed, 07 Feb 2007 13:35:57 GMT]]></title><description><![CDATA[<p>Hab es jetzt so geschrieben:</p>
<pre><code>vector&lt;string&gt; tri; 

    for(int i=0;i&lt;test.length();i=i+3) 
   { 
      tri.push_back(test.substr(i,3)); 
   }

   for(int i = 0;i &lt; test.length();++i)
   {
           if (tri[i] == &quot;ABC&quot;) 
           {
               tri[i] = &quot;Alphabet&quot;;
           }

   }

   for(int i = 0;i &lt; test.length();++i)
   {
           cout &lt;&lt; tri[i];
   }
</code></pre>
<p>Beim Ausführen wenn ich ABC eingebe kommt allerdings ein Fehler...Programm hat einen Fehler festgestellt, bericht senden nicht senden .... der Compiler hat es kompiliert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1224431</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1224431</guid><dc:creator><![CDATA[Dieder]]></dc:creator><pubDate>Wed, 07 Feb 2007 13:35:57 GMT</pubDate></item><item><title><![CDATA[Reply to Substring in Schleife on Wed, 07 Feb 2007 14:01:41 GMT]]></title><description><![CDATA[<p>Du mußt schon die richtige Längenangabe nehmen für deine Schleife - du hast je drei Zeichen von &quot;test&quot; zu einem Element von &quot;tri&quot; zusammengefasst, also ist tri auch ein ganzes Stück kürzer (und Zugriffe jenseits des erlaubten Bereiches quittiert das System mit derartigen Fehlermeldungen).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1224454</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1224454</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 07 Feb 2007 14:01:41 GMT</pubDate></item><item><title><![CDATA[Reply to Substring in Schleife on Wed, 07 Feb 2007 15:01:09 GMT]]></title><description><![CDATA[<p>Hey danke, hat alles geklappt, jetzt nur noch ein letztes Problem:</p>
<p>Wie überprüfe ich, ob andere Buchstaben ausser ATGC eingegeben wurden? Danke für die Hilfe,</p>
<p>Dieder</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1224482</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1224482</guid><dc:creator><![CDATA[Dieder]]></dc:creator><pubDate>Wed, 07 Feb 2007 15:01:09 GMT</pubDate></item><item><title><![CDATA[Reply to Substring in Schleife on Wed, 07 Feb 2007 15:24:13 GMT]]></title><description><![CDATA[<p>Hallo Polyeder,</p>
<p>Dieder schrieb:</p>
<blockquote>
<p>Wie überprüfe ich, ob andere Buchstaben ausser ATGC eingegeben wurden?</p>
</blockquote>
<p>Kurze Antwort: 'find_first_not_of'.</p>
<p>Lange Antwort:</p>
<pre><code class="language-cpp">string DNA = &quot;ACTGTAGAGCX&quot;;

bool contains_invalid_char = DNA.find_first_not_of(&quot;ACGT&quot;) != string::npos;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1224504</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1224504</guid><dc:creator><![CDATA[Konrad Rudolph]]></dc:creator><pubDate>Wed, 07 Feb 2007 15:24:13 GMT</pubDate></item></channel></rss>