<?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[auf anfang eines sring matchen]]></title><description><![CDATA[<p>hallo,<br />
ich lese ein file ein und möchte über alle leerzeilen und kommentare hinwegspringen ...<br />
dazu muss ich aber jede zeile am anfang vergleichen..</p>
<p>wie kann ich den prinzipiell einen string auf die anfangs character testen?<br />
string.start oder sowas?</p>
<p>oder sind regular expressions die bessere wahl für mein vorhaben?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/122274/auf-anfang-eines-sring-matchen</link><generator>RSS for Node</generator><lastBuildDate>Sun, 23 Aug 2026 00:34:12 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/122274.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 02 Oct 2005 19:18:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to auf anfang eines sring matchen on Sun, 02 Oct 2005 19:18:29 GMT]]></title><description><![CDATA[<p>hallo,<br />
ich lese ein file ein und möchte über alle leerzeilen und kommentare hinwegspringen ...<br />
dazu muss ich aber jede zeile am anfang vergleichen..</p>
<p>wie kann ich den prinzipiell einen string auf die anfangs character testen?<br />
string.start oder sowas?</p>
<p>oder sind regular expressions die bessere wahl für mein vorhaben?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/884735</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/884735</guid><dc:creator><![CDATA[mattt]]></dc:creator><pubDate>Sun, 02 Oct 2005 19:18:29 GMT</pubDate></item><item><title><![CDATA[Reply to auf anfang eines sring matchen on Sun, 02 Oct 2005 19:30:49 GMT]]></title><description><![CDATA[<p>str[0] <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/884737</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/884737</guid><dc:creator><![CDATA[[0]]]></dc:creator><pubDate>Sun, 02 Oct 2005 19:30:49 GMT</pubDate></item><item><title><![CDATA[Reply to auf anfang eines sring matchen on Sun, 02 Oct 2005 21:42:10 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">bool isemptyline(string in){
  for(int i = 0; i&lt;in.size(); i++){
    if (string.c_str()[i] &gt; 32) return false;
  }
  return true;
}
</code></pre>
<p>Die Funktion sollte testen, ob der String den du übergibts &quot;normale&quot; Zeichen enthält.<br />
Gibt false zurück, wenn es einen Buchstaben oder ähnliches findet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/884798</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/884798</guid><dc:creator><![CDATA[imhotep]]></dc:creator><pubDate>Sun, 02 Oct 2005 21:42:10 GMT</pubDate></item><item><title><![CDATA[Reply to auf anfang eines sring matchen on Mon, 03 Oct 2005 10:52:30 GMT]]></title><description><![CDATA[<p>ja er will aber nur testen ob die zeile gerade leer ist oder kommentar enthält</p>
<p>wenn du zeilenweise einliest, dann prüfe ( ob leerzeile )</p>
<pre><code class="language-cpp">if( !currentLine.IsEmpty() ) {

  if ( !ContainComment( currentline ) ) {

      // ja ich bin keine leerzeile und enthalte keinen kommentar

  }

}

// ob kommentar ist könnte man so überprüfen

bool ContainComment( const string &amp;str ) {

  bool bReturn = true;

  if( str.Find(&quot;//&quot;) {    // hier dein argument wie man comments definiert, hier mal c++ like
    bReturn = false;
  }

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/884964</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/884964</guid><dc:creator><![CDATA[mrsTux]]></dc:creator><pubDate>Mon, 03 Oct 2005 10:52:30 GMT</pubDate></item><item><title><![CDATA[Reply to auf anfang eines sring matchen on Mon, 03 Oct 2005 10:55:12 GMT]]></title><description><![CDATA[<p>ups</p>
<p>sollte natürlich</p>
<pre><code class="language-cpp">bool ContainComment( const string &amp;str ) {

  bool bReturn = true;

  if( str.Find(&quot;//&quot;) {    // hier dein argument wie man comments definiert, hier mal c++ like
    bReturn = false;
  }

return bReturn; // &lt;&lt;&lt;------ hat gefehlt :(

}
</code></pre>
<p>statt</p>
<p>// ja ich bin keine leerzeile und enthalte keinen kommentar</p>
<p>machst du z.b.</p>
<p>.push_back<br />
oder<br />
.SaveMe</p>
<p>oder so was in der art</p>
]]></description><link>https://www.c-plusplus.net/forum/post/884965</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/884965</guid><dc:creator><![CDATA[mrsTux]]></dc:creator><pubDate>Mon, 03 Oct 2005 10:55:12 GMT</pubDate></item><item><title><![CDATA[Reply to auf anfang eines sring matchen on Mon, 03 Oct 2005 11:12:17 GMT]]></title><description><![CDATA[<p>Gut mit den Kommentaren muss man die Funktion erweitern.</p>
<p>@ mrsTux Außerdem kann es sein, dass // in einem String steht, also muss man das auch noch erkennen.</p>
<pre><code class="language-cpp">int irgnore_line(string in){
  int back;
  for(int i = 0; i&lt;in.size(); i++){
    if (string.c_str()[i] &gt; 32) {
      if ( ( string.c_str()[i] == '/' ) &amp;&amp; (string.size &gt; i) &amp;&amp; (string.c_str()[i + 1] == '/') ) return 2;
      else return 0;
    } 
  }
  return 1;
}
</code></pre>
<p>So erkennt man ob es ein Leerzeile (return 1), eine Kommentarzeile (return 2) oder eine Textzeile (return 0) ist. Bei mehrzeiligen Kommentaren ala &quot;/*&quot; müsste man noch eine Funktion schaffen, die erkennt, dass ein Kommentar aufhört.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/884985</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/884985</guid><dc:creator><![CDATA[imhotep]]></dc:creator><pubDate>Mon, 03 Oct 2005 11:12:17 GMT</pubDate></item><item><title><![CDATA[Reply to auf anfang eines sring matchen on Mon, 03 Oct 2005 11:18:10 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">bool ContainComment( const string &amp;str ) {

  bool bReturn = true;

  if( str.Find(&quot;//&quot;) {    // hier dein argument wie man comments definiert, hier mal c++ like
    bReturn = false;
  }

return bReturn; // &lt;&lt;&lt;------ hat gefehlt :(

}
</code></pre>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/27a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--right_arrow"
      title=":arrow_right:"
      alt="➡"
    /></p>
<pre><code class="language-cpp">bool ContainComment(const string &amp;str)
{
    return str.Find(&quot;//&quot;);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/884990</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/884990</guid><dc:creator><![CDATA[WTFFFFF]]></dc:creator><pubDate>Mon, 03 Oct 2005 11:18:10 GMT</pubDate></item><item><title><![CDATA[Reply to auf anfang eines sring matchen on Mon, 03 Oct 2005 12:08:05 GMT]]></title><description><![CDATA[<p>imhotep schrieb:</p>
<blockquote>
<p>Gut mit den Kommentaren muss man die Funktion erweitern.</p>
<p>@ mrsTux Außerdem kann es sein, dass // in einem String steht, also muss man das auch noch erkennen.</p>
<p>if ( ( string.c_str()[i] == '/' ) &amp;&amp; (string.size &gt; i) &amp;&amp; (string.c_str()[i + 1] == '/') ) return 2;</p>
<p>[/cpp]</p>
</blockquote>
<p>1. es war ja nur ein grundprinzip ( das mit den kommentaren muss man halt sprachspez anpssen<br />
2. soviel ich weiss heisst Find(&quot;//&quot;); das // hintereinander stehen muss. und das prüfst du ja mit</p>
<p>[i] = &quot;/&quot; und [i+1] = &quot;/&quot;</p>
<p>und das ist überflüssig</p>
<p>ausser string würde anders als Cstring sein, was ich bei einer find fkt nicht glaube</p>
]]></description><link>https://www.c-plusplus.net/forum/post/885036</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/885036</guid><dc:creator><![CDATA[mrsTux]]></dc:creator><pubDate>Mon, 03 Oct 2005 12:08:05 GMT</pubDate></item></channel></rss>