<?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[Wörter zählen]]></title><description><![CDATA[<pre><code class="language-cpp">void __fastcall TForm1::Edit2KeyDown(TObject *Sender, WORD &amp;Key,
      TShiftState Shift)
{
 if(Key==13)
  {
  int x,counter;
  String Eingabe;
  counter=0;
  Eingabe=Edit1-&gt;Text;

    for(x=1;x&lt;=Eingabe.Length;x++)
     {
       if (Eingabe[x]==' ')
       {
       counter++;
       }
     Label1-&gt;Visible=true;
     Label1-&gt;Caption=IntToStr(summe);
     }
  }
}
</code></pre>
<p>hallo kann mir einer sagen warum das obrige Prog. nicht funktioniert und könnt ihr mir den Code auch ausbessern und richtig stellen? bitte danke.<br />
Also es geht ums Wörter zählen.<br />
ich komm alleine nicht drauf... : (</p>
<p>MFG</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/174788/wörter-zählen</link><generator>RSS for Node</generator><lastBuildDate>Fri, 18 Sep 2026 22:44:52 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/174788.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 03 Mar 2007 18:32:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Wörter zählen on Sat, 03 Mar 2007 18:32:01 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">void __fastcall TForm1::Edit2KeyDown(TObject *Sender, WORD &amp;Key,
      TShiftState Shift)
{
 if(Key==13)
  {
  int x,counter;
  String Eingabe;
  counter=0;
  Eingabe=Edit1-&gt;Text;

    for(x=1;x&lt;=Eingabe.Length;x++)
     {
       if (Eingabe[x]==' ')
       {
       counter++;
       }
     Label1-&gt;Visible=true;
     Label1-&gt;Caption=IntToStr(summe);
     }
  }
}
</code></pre>
<p>hallo kann mir einer sagen warum das obrige Prog. nicht funktioniert und könnt ihr mir den Code auch ausbessern und richtig stellen? bitte danke.<br />
Also es geht ums Wörter zählen.<br />
ich komm alleine nicht drauf... : (</p>
<p>MFG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1238618</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1238618</guid><dc:creator><![CDATA[LoSt]]></dc:creator><pubDate>Sat, 03 Mar 2007 18:32:01 GMT</pubDate></item><item><title><![CDATA[Reply to Wörter zählen on Sat, 03 Mar 2007 18:33:54 GMT]]></title><description><![CDATA[<p>Hast du das schon mal versucht?<br />
<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-120832.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-120832.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1238620</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1238620</guid><dc:creator><![CDATA[tzername:]]></dc:creator><pubDate>Sat, 03 Mar 2007 18:33:54 GMT</pubDate></item><item><title><![CDATA[Reply to Wörter zählen on Sat, 03 Mar 2007 18:39:54 GMT]]></title><description><![CDATA[<p>nö weil</p>
<blockquote>
<p>Dieser Artikel bezieht sich auf Visual C++ 6 (SP6)</p>
</blockquote>
<p>ich benütz den c++ builder 3 von borland. und ich bleib auch bei dem :p</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1238624</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1238624</guid><dc:creator><![CDATA[LoSt]]></dc:creator><pubDate>Sat, 03 Mar 2007 18:39:54 GMT</pubDate></item><item><title><![CDATA[Reply to Wörter zählen on Sat, 03 Mar 2007 19:18:03 GMT]]></title><description><![CDATA[<p>Ich bin mir sicher, dass man mit dem auch debuggen kann, auch man breakpoints mit ner anderen Tastenkombination setzt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1238634</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1238634</guid><dc:creator><![CDATA[tzername:]]></dc:creator><pubDate>Sat, 03 Mar 2007 19:18:03 GMT</pubDate></item><item><title><![CDATA[Reply to Wörter zählen on Sat, 03 Mar 2007 19:19:35 GMT]]></title><description><![CDATA[<p>tzername: schrieb:</p>
<blockquote>
<p>breakpoints mit ner anderen Tastenkombination setzt.</p>
</blockquote>
<p>na toll</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1238636</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1238636</guid><dc:creator><![CDATA[LoSt]]></dc:creator><pubDate>Sat, 03 Mar 2007 19:19:35 GMT</pubDate></item><item><title><![CDATA[Reply to Wörter zählen on Sat, 03 Mar 2007 19:25:20 GMT]]></title><description><![CDATA[<p>Was? Ist es zu schwer für dich nachzuschauen, wie man nen Breakpoint setzt? Irgenwann musst du debuggen, wenn du was größeres programmieren willst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1238641</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1238641</guid><dc:creator><![CDATA[tzername:]]></dc:creator><pubDate>Sat, 03 Mar 2007 19:25:20 GMT</pubDate></item><item><title><![CDATA[Reply to Wörter zählen on Sat, 03 Mar 2007 19:34:38 GMT]]></title><description><![CDATA[<p>ja aber jetz noch nicht. ich wende nur befehle an die ich auch in der schule gelernt habe.<br />
und jetzt zurück zu meinem Syntax-Problem..<br />
Kann jmd den &quot;Fehler&quot; ausbessern?<br />
mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1238646</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1238646</guid><dc:creator><![CDATA[LoSt]]></dc:creator><pubDate>Sat, 03 Mar 2007 19:34:38 GMT</pubDate></item><item><title><![CDATA[Reply to Wörter zählen on Sat, 03 Mar 2007 19:38:41 GMT]]></title><description><![CDATA[<p>Wie Syntaxproblem, gibts ne compilerfehlermeldung?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1238648</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1238648</guid><dc:creator><![CDATA[tzername:]]></dc:creator><pubDate>Sat, 03 Mar 2007 19:38:41 GMT</pubDate></item><item><title><![CDATA[Reply to Wörter zählen on Sat, 03 Mar 2007 19:41:04 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">for(x=1;x&lt;=Eingabe.Length;x++)
</code></pre>
<p>[C++Fehler] Unit1.cpp(77): Member function must be called or its address taken.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1238650</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1238650</guid><dc:creator><![CDATA[LoSt]]></dc:creator><pubDate>Sat, 03 Mar 2007 19:41:04 GMT</pubDate></item><item><title><![CDATA[Reply to Wörter zählen on Sat, 03 Mar 2007 19:49:06 GMT]]></title><description><![CDATA[<p>Hi,<br />
hast nicht gesagt wo das Problem GENAU lag daher hab ich einfach das hier gebastelt müsstest du allerdings anpassen</p>
<pre><code class="language-cpp">int nWordCounter = 1;
char *strDeinText = &quot;Hallo Welt, aber diesmal mit einigen Leerzeichen mehr . . .&quot;;
char *strTemp;
for ( int i = 0; i &lt; strlen( strDeinText ); i++ )
{
	if ( strDeinText[i] == ' ' )
	{
		nWordCounter++;
		//printf( &quot;\n&quot; );
	}
	else
	{
	        //printf( &quot;%c&quot;, strDeinText[i] );
	}
}
//printf( &quot;\n\n--&gt; %d\n\n&quot;, nWordCounter );
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1238654</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1238654</guid><dc:creator><![CDATA[Blubbbbb]]></dc:creator><pubDate>Sat, 03 Mar 2007 19:49:06 GMT</pubDate></item><item><title><![CDATA[Reply to Wörter zählen on Sat, 03 Mar 2007 19:50:28 GMT]]></title><description><![CDATA[<p>Wenn überhaupt Eingabe.length**()**</p>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1238656</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1238656</guid><dc:creator><![CDATA[Blubbbbb]]></dc:creator><pubDate>Sat, 03 Mar 2007 19:50:28 GMT</pubDate></item><item><title><![CDATA[Reply to Wörter zählen on Sat, 03 Mar 2007 20:26:34 GMT]]></title><description><![CDATA[<p>Blubbbbb schrieb:</p>
<blockquote>
<p>Wenn überhaupt Eingabe.length**()**</p>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
</blockquote>
<p>danke^^ hätt ich auch selber draufkommen können<br />
naja jetzt tut sich gar nix wenn ich auf enter drück bei edit nach der wörter eingabe.</p>
<p>..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1238670</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1238670</guid><dc:creator><![CDATA[LoSt]]></dc:creator><pubDate>Sat, 03 Mar 2007 20:26:34 GMT</pubDate></item><item><title><![CDATA[Reply to Wörter zählen on Sun, 04 Mar 2007 11:00:08 GMT]]></title><description><![CDATA[<p>bitte helfen .. is wichtig <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1238840</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1238840</guid><dc:creator><![CDATA[LoSt]]></dc:creator><pubDate>Sun, 04 Mar 2007 11:00:08 GMT</pubDate></item><item><title><![CDATA[Reply to Wörter zählen on Sun, 04 Mar 2007 15:08:07 GMT]]></title><description><![CDATA[<p>LoSt schrieb:</p>
<blockquote>
<p>bitte helfen .. is wichtig <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
</blockquote>
<p>Hat wieder keiner gesehen, ist aber ganz einfach. Dein Index 'x' läuft von 1 bis Eingabe.Length() - korrekt ist 0 bis Eingabe.Length()-1. Also in Zeile 11:</p>
<pre><code class="language-cpp">for( x=0; x&lt;Eingabe.Length(); x++ )
</code></pre>
<p>Angenommen je zwei Wörter sind durch genau ein Leerzeichen getrennt und vor dem ersten Wort und hinter dem letzten Wort befindet sich kein Leerzeichen, so ist die Anzahl der Wörter = Anzahl der Leerzeichen plus 1. Also ändere Zeile 9 noch nach:</p>
<pre><code class="language-cpp">counter=1;
</code></pre>
<p>.. und Zeile 18 müsste doch eher</p>
<pre><code class="language-cpp">Label1-&gt;Caption=IntToStr(counter);
</code></pre>
<p>heißen - oder?</p>
<p>Tipp: verwende ausschließlich lokale Variablen.</p>
<p>Eine sicher Alternative ist:</p>
<pre><code class="language-cpp">istringstream buf( Eingabe ); // oder ähnlich
    counter = distance( istream_iterator&lt; string &gt;( buf ), istream_iterator&lt; string &gt;() );
</code></pre>
<p>erfordert includes: &lt;sstream&gt;, &lt;iterator&gt; und &lt;algorithm&gt;.<br />
Die Alternative ist auch robust gegenüber führenden und endenden Leerzeichen und mehr als ein Leerzeichen zwischen zwei Wörtern.</p>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1239019</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1239019</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Sun, 04 Mar 2007 15:08:07 GMT</pubDate></item><item><title><![CDATA[Reply to Wörter zählen on Sun, 04 Mar 2007 18:16:06 GMT]]></title><description><![CDATA[<p>löschn</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1239050</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1239050</guid><dc:creator><![CDATA[LoSt]]></dc:creator><pubDate>Sun, 04 Mar 2007 18:16:06 GMT</pubDate></item><item><title><![CDATA[Reply to Wörter zählen on Sun, 04 Mar 2007 18:19:21 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">{
 if(Key==13)
  {
  int x,counter;
  String Eingabe;
  counter=1;
  Eingabe=Edit2-&gt;Text;

    for(x=0;x&lt;Eingabe.Length();x++)
     {
       if (Eingabe[x]==' ')
       {
       counter++;
       }
     Label4-&gt;Visible=true;
     Label4-&gt;Caption=IntToStr(counter);
     }
  }
}
</code></pre>
<p>so hab ich es jetzt und bekomm ne &quot;fehlermeldung&quot;:<br />
<a href="http://www.directupload.net/file/d/991/945s4OXb_jpg.htm" rel="nofollow">http://www.directupload.net/images/070304/temp/945s4OXb.jpg</a></p>
<p>kan mir wer helfen, damit das prog jetzt endlich funzt? danke</p>
<p>EDIT:<br />
ok mit<br />
[cpp] for(x=<strong>1</strong>;x&lt;Eingabe.Length();x++)[/cpp]<br />
geht es!!<br />
danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1239124</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1239124</guid><dc:creator><![CDATA[LoSt]]></dc:creator><pubDate>Sun, 04 Mar 2007 18:19:21 GMT</pubDate></item><item><title><![CDATA[Reply to Wörter zählen on Mon, 05 Mar 2007 10:30:49 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Fragen bezüglich des BCB solltest du auch in dem dortigen Forum stellen. Dort hätte man gewußt, dass die Zählung der AnsiStrings mit 1 beginnt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1239397</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1239397</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Mon, 05 Mar 2007 10:30:49 GMT</pubDate></item></channel></rss>