<?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[Segmentation fault]]></title><description><![CDATA[<p>Hi,</p>
<p>ich mache gerade meine ersten Schritte in C++ und habe mir dafür ein Buch gekauft.</p>
<p>Wenn ich nun folgendes Beispiel in meinem Dev-Cpp Compiler ausführen möchte, stürzt immer das Programm ab und es kommt die Meldung: &quot;Eine Zugriffsverletzung (Segmentation fault) trat in Ihrem Programm auf.&quot;<br />
Er compiliert es allerdings ohne Probleme.</p>
<pre><code>#include&lt;ctype.h&gt;
#include&lt;iostream.h&gt;

int *pS;

void upperCase(char *pS)
{
     while (*pS)
     {
               if (islower(*pS))
               {
                *pS = toupper(*pS);  //Zugriffsverletzung
               }

               pS++;
     }
}

void fn()
{
     char *pString= &quot;Test&quot;;
     cout &lt;&lt; pString &lt;&lt; endl;

     upperCase(pString);
     cout &lt;&lt; pString &lt;&lt; endl;

}

int main()
{
          cout &lt;&lt; &quot;Los! &quot; &lt;&lt; endl &lt;&lt; endl;
          fn();
          while(1);
          return 0;
}
</code></pre>
<p>Weiß jemand woran das liegen kann?<br />
Muss ich vielleicht noch Speicher freigeben oder so etwas?</p>
<p>Vielen Dank im Voraus</p>
<p>MfG<br />
Stephan01</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/144069/segmentation-fault</link><generator>RSS for Node</generator><lastBuildDate>Wed, 02 Sep 2026 13:11:18 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/144069.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 14 Apr 2006 09:25:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Segmentation fault on Fri, 14 Apr 2006 09:25:33 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich mache gerade meine ersten Schritte in C++ und habe mir dafür ein Buch gekauft.</p>
<p>Wenn ich nun folgendes Beispiel in meinem Dev-Cpp Compiler ausführen möchte, stürzt immer das Programm ab und es kommt die Meldung: &quot;Eine Zugriffsverletzung (Segmentation fault) trat in Ihrem Programm auf.&quot;<br />
Er compiliert es allerdings ohne Probleme.</p>
<pre><code>#include&lt;ctype.h&gt;
#include&lt;iostream.h&gt;

int *pS;

void upperCase(char *pS)
{
     while (*pS)
     {
               if (islower(*pS))
               {
                *pS = toupper(*pS);  //Zugriffsverletzung
               }

               pS++;
     }
}

void fn()
{
     char *pString= &quot;Test&quot;;
     cout &lt;&lt; pString &lt;&lt; endl;

     upperCase(pString);
     cout &lt;&lt; pString &lt;&lt; endl;

}

int main()
{
          cout &lt;&lt; &quot;Los! &quot; &lt;&lt; endl &lt;&lt; endl;
          fn();
          while(1);
          return 0;
}
</code></pre>
<p>Weiß jemand woran das liegen kann?<br />
Muss ich vielleicht noch Speicher freigeben oder so etwas?</p>
<p>Vielen Dank im Voraus</p>
<p>MfG<br />
Stephan01</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1037318</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1037318</guid><dc:creator><![CDATA[Stephan01]]></dc:creator><pubDate>Fri, 14 Apr 2006 09:25:33 GMT</pubDate></item><item><title><![CDATA[Reply to Segmentation fault on Fri, 14 Apr 2006 09:30:04 GMT]]></title><description><![CDATA[<p>Du darfst keine String Literals verändern, der Fehler ist dass es</p>
<p>const char *pString= &quot;Test&quot;;</p>
<p>heißt. Du brauchst sowas:</p>
<p>char pString[] = &quot;Test&quot;;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1037321</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1037321</guid><dc:creator><![CDATA[Cool-O-Meter |XX--------|]]></dc:creator><pubDate>Fri, 14 Apr 2006 09:30:04 GMT</pubDate></item><item><title><![CDATA[Reply to Segmentation fault on Fri, 14 Apr 2006 09:38:57 GMT]]></title><description><![CDATA[<p>Hey Wahnsinn es hat funktioniert!</p>
<p>Nur, kann mir das mit den String Literals jemand erklären?<br />
Und warum steht es in dem Buch dann falsch?</p>
<p>MfG<br />
Stephan01</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1037327</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1037327</guid><dc:creator><![CDATA[Stephan01]]></dc:creator><pubDate>Fri, 14 Apr 2006 09:38:57 GMT</pubDate></item></channel></rss>