<?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[Erste 8 Buchstaben von char String]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich hätte da mal eine Frage, welche ihr mir sicherlich beantworten könnt.<br />
Ich hab eine Hexadezimale die ich in eine Dezimale konvertiere. Da dies von woanders abgerufen wird, gibt's folgendes Problem:<br />
die 8-stellige Dezimale hat laut strlen insgesammt 10 zeichen. Ich kann zwar nicht ganz nachvollziehen wie es zu soetwas kommen kann, aber fakt ist, dass ich jetzt die ersten 8 Stellen des chars brauche.</p>
<p>Als erstes dachte ich an die Funktion sprintf, aber die hilft mir nicht recht ...</p>
<p>Vielen Dank!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/278428/erste-8-buchstaben-von-char-string</link><generator>RSS for Node</generator><lastBuildDate>Tue, 25 Aug 2026 06:20:46 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/278428.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 06 Dec 2010 18:31:14 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Erste 8 Buchstaben von char String on Mon, 06 Dec 2010 18:31:14 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich hätte da mal eine Frage, welche ihr mir sicherlich beantworten könnt.<br />
Ich hab eine Hexadezimale die ich in eine Dezimale konvertiere. Da dies von woanders abgerufen wird, gibt's folgendes Problem:<br />
die 8-stellige Dezimale hat laut strlen insgesammt 10 zeichen. Ich kann zwar nicht ganz nachvollziehen wie es zu soetwas kommen kann, aber fakt ist, dass ich jetzt die ersten 8 Stellen des chars brauche.</p>
<p>Als erstes dachte ich an die Funktion sprintf, aber die hilft mir nicht recht ...</p>
<p>Vielen Dank!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1990652</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1990652</guid><dc:creator><![CDATA[Andiix3]]></dc:creator><pubDate>Mon, 06 Dec 2010 18:31:14 GMT</pubDate></item><item><title><![CDATA[Reply to Erste 8 Buchstaben von char String on Mon, 06 Dec 2010 18:34:32 GMT]]></title><description><![CDATA[<p>Muss es denn ein char-String sein?<br />
Ansonsten klappt alles mit sprintf und scanf.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1990657</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1990657</guid><dc:creator><![CDATA[cppstring]]></dc:creator><pubDate>Mon, 06 Dec 2010 18:34:32 GMT</pubDate></item><item><title><![CDATA[Reply to Erste 8 Buchstaben von char String on Mon, 06 Dec 2010 18:45:08 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;stdio.h&gt;
#include &lt;string.h&gt;

void printSubstring(const char *str, unsigned int count);

int main()
{
	char str[100];

	sprintf(str, &quot;Dies ist der String.&quot;);

	// Gesamte Ausgabe
	printf(&quot;%s\n&quot;, str);

	// Limitierte Ausgabe
	printSubstring(str, 8);

	return 0;
}

void printSubstring(const char *str, unsigned int count)
{
	unsigned int i, len;

	len = strlen(str);

	if (count &gt; len)
	{
		count = len;
	}

	for (i = 0; i &lt; count; ++i)
	{
		putchar(str[i]);
	}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1990663</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1990663</guid><dc:creator><![CDATA[jhghj]]></dc:creator><pubDate>Mon, 06 Dec 2010 18:45:08 GMT</pubDate></item><item><title><![CDATA[Reply to Erste 8 Buchstaben von char String on Mon, 06 Dec 2010 18:48:02 GMT]]></title><description><![CDATA[<p>Alternativ:</p>
<pre><code class="language-cpp">#include &lt;stdio.h&gt;
#include &lt;string.h&gt;

int main()
{
	char str[100];

	sprintf(str, &quot;123456789&quot;);

	printf(&quot;-- Vorher --\nLen: %i\nStr: %s\n\n&quot;, strlen(str), str);

	str[8] = '\0';

	printf(&quot;-- Nachher --\nLen: %i\nStr: %s\n\n&quot;, strlen(str), str);

	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1990666</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1990666</guid><dc:creator><![CDATA[jhghj]]></dc:creator><pubDate>Mon, 06 Dec 2010 18:48:02 GMT</pubDate></item><item><title><![CDATA[Reply to Erste 8 Buchstaben von char String on Mon, 06 Dec 2010 18:51:44 GMT]]></title><description><![CDATA[<p>Bei ?printf geht auch &quot;%-8.8s&quot; als Format. Das gibt 8 Zeichen linksbündig aus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1990668</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1990668</guid><dc:creator><![CDATA[DirkB]]></dc:creator><pubDate>Mon, 06 Dec 2010 18:51:44 GMT</pubDate></item></channel></rss>