<?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[C-Strings]]></title><description><![CDATA[<p>Hi,<br />
ich hab mal ne frage zu dem Quelltext:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;

int main(){
  char name[30];
  char* zeiger = name;

  cout&lt;&lt;&quot;Wie heißten Sie?&quot;&lt;&lt;endl;
  cin&gt;&gt;name;
  if(name[2] = ){     // Was gehört da rein? Um zu prüfen,
                      // ob der name[2] nicht leer bzw. NULL ist?
                      // if(name[2] = &quot;&quot;) ?
    cerr&lt;&lt;&quot;Ihr Name hat keinen 3. Buchstaben!&quot;&lt;&lt;endl;
    exit(1);
  }
  cout&lt;&lt;&quot;Der dritte Buchstabe Ihres Namens ist ein \'&quot;&lt;&lt;zeiger[2]&lt;&lt;&quot;\'&quot;&lt;&lt;endl;
  system(&quot;PAUSE&quot;);
  return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/194263/c-strings</link><generator>RSS for Node</generator><lastBuildDate>Mon, 28 Sep 2026 08:49:24 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/194263.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 04 Oct 2007 15:26:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to C-Strings on Thu, 04 Oct 2007 15:26:52 GMT]]></title><description><![CDATA[<p>Hi,<br />
ich hab mal ne frage zu dem Quelltext:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;

int main(){
  char name[30];
  char* zeiger = name;

  cout&lt;&lt;&quot;Wie heißten Sie?&quot;&lt;&lt;endl;
  cin&gt;&gt;name;
  if(name[2] = ){     // Was gehört da rein? Um zu prüfen,
                      // ob der name[2] nicht leer bzw. NULL ist?
                      // if(name[2] = &quot;&quot;) ?
    cerr&lt;&lt;&quot;Ihr Name hat keinen 3. Buchstaben!&quot;&lt;&lt;endl;
    exit(1);
  }
  cout&lt;&lt;&quot;Der dritte Buchstabe Ihres Namens ist ein \'&quot;&lt;&lt;zeiger[2]&lt;&lt;&quot;\'&quot;&lt;&lt;endl;
  system(&quot;PAUSE&quot;);
  return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1378009</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1378009</guid><dc:creator><![CDATA[daLord]]></dc:creator><pubDate>Thu, 04 Oct 2007 15:26:52 GMT</pubDate></item><item><title><![CDATA[Reply to C-Strings on Thu, 04 Oct 2007 15:33:16 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">if(name[0] == '\0' || name[1] == '\0' || name[2] == '\0')
</code></pre>
<p>Du willst ja prüfen, ob der Name weniger als 3 Zeichen hat. Das ist der Fall wenn das Zeichen zum Ende des Strings an 1, 2, oder 3. Stelle des Strings steht.</p>
<p>Auf Gleichheit prüft man übrigens mit == und nicht mit = (relativ häufiger Fehler). Ansonsten würde ich mir noch std::string ansehen und nicht unbedingt mit rohen C-Strings arbeiten.</p>
<p>Felix</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1378013</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1378013</guid><dc:creator><![CDATA[Phoemuex]]></dc:creator><pubDate>Thu, 04 Oct 2007 15:33:16 GMT</pubDate></item><item><title><![CDATA[Reply to C-Strings on Thu, 04 Oct 2007 15:51:56 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">if( strlen(name) &lt; 3)
</code></pre>
<p>tut es auch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1378031</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1378031</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Thu, 04 Oct 2007 15:51:56 GMT</pubDate></item></channel></rss>