<?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[Wieso Segmentation fault ??]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte einfach nur eine Zahl in ein ASCII Zeichen umwandeln und dann per sprintf in eine Ausgabezeile schreiben. Dabei erscheint bei meiner sprintf Anweisung immer &quot;Segmentation fault&quot;. Das kompilieren geht problemlos (mit g++). Könnte vielleicht jemand so freundlich sein und mich auf den Fehler hinweisen. Weil ich echt nicht verstehe, wieso das nicht funktioniert.</p>
<p>Vielen Dank</p>
<p>\1:<br />
----------------------------------------------------<br />
int zahl = 66;<br />
char message[256];</p>
<p>char wert = (char)zahl;<br />
cout &lt;&lt; wert &lt;&lt; endl;<br />
sprintf(message,&quot;ASCII: %s&quot;,wert);<br />
cout &lt;&lt; message &lt;&lt; endl;<br />
-----------------------------------------------------</p>
<p>Ausgabe:<br />
-----------------------------------------------------<br />
B<br />
Segmentation fault</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/195221/wieso-segmentation-fault</link><generator>RSS for Node</generator><lastBuildDate>Tue, 29 Sep 2026 21:16:29 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/195221.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 15 Oct 2007 14:57:36 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Wieso Segmentation fault ?? on Mon, 15 Oct 2007 14:57:36 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte einfach nur eine Zahl in ein ASCII Zeichen umwandeln und dann per sprintf in eine Ausgabezeile schreiben. Dabei erscheint bei meiner sprintf Anweisung immer &quot;Segmentation fault&quot;. Das kompilieren geht problemlos (mit g++). Könnte vielleicht jemand so freundlich sein und mich auf den Fehler hinweisen. Weil ich echt nicht verstehe, wieso das nicht funktioniert.</p>
<p>Vielen Dank</p>
<p>\1:<br />
----------------------------------------------------<br />
int zahl = 66;<br />
char message[256];</p>
<p>char wert = (char)zahl;<br />
cout &lt;&lt; wert &lt;&lt; endl;<br />
sprintf(message,&quot;ASCII: %s&quot;,wert);<br />
cout &lt;&lt; message &lt;&lt; endl;<br />
-----------------------------------------------------</p>
<p>Ausgabe:<br />
-----------------------------------------------------<br />
B<br />
Segmentation fault</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1385713</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1385713</guid><dc:creator><![CDATA[fettyteddy2]]></dc:creator><pubDate>Mon, 15 Oct 2007 14:57:36 GMT</pubDate></item><item><title><![CDATA[Reply to Wieso Segmentation fault ?? on Mon, 15 Oct 2007 14:59:18 GMT]]></title><description><![CDATA[<p>wert ist kein string, sondern ein char, könnte sein, dass es daher kommt, probier mal</p>
<pre><code class="language-cpp">sprintf(message, &quot;ASCII: %c&quot;, wert)
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1385716</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1385716</guid><dc:creator><![CDATA[Vorden]]></dc:creator><pubDate>Mon, 15 Oct 2007 14:59:18 GMT</pubDate></item><item><title><![CDATA[Reply to Wieso Segmentation fault ?? on Mon, 15 Oct 2007 15:03:36 GMT]]></title><description><![CDATA[<p>äm ja hast recht... echt doof das ich da nicht drauf gekommen bin. Geht.. danke!!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1385722</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1385722</guid><dc:creator><![CDATA[fettyteddy2]]></dc:creator><pubDate>Mon, 15 Oct 2007 15:03:36 GMT</pubDate></item><item><title><![CDATA[Reply to Wieso Segmentation fault ?? on Mon, 15 Oct 2007 15:05:34 GMT]]></title><description><![CDATA[<p>Wie wäre es mit stringstreams?</p>
<pre><code>int zahl = 66;
std::string message;

char wert = static_cast&lt;char&gt;(zahl);
std::cout &lt;&lt; wert &lt;&lt; std::endl;
std::ostringstream ss;
ss &lt;&lt; &quot;ASCII: &quot; &lt;&lt; wert;
message = ss.str();
std::cout &lt;&lt; message &lt;&lt; std::endl;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1385724</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1385724</guid><dc:creator><![CDATA[stringstream]]></dc:creator><pubDate>Mon, 15 Oct 2007 15:05:34 GMT</pubDate></item></channel></rss>