<?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[auslesen von chars schlägt fehl.]]></title><description><![CDATA[<p>Hallo habe ein chararray aus dem ein teil der chars auslesen und in ein neues chararray packen will.</p>
<pre><code>//fill origin string geht ohne probleme
char *Taskstring = new char[length+1];
memset(Taskstring, '\0', length+1);
char byte[1];
for (int h=0; h &lt; length ;h++){
 byte[0] = file.readUint8();
 strncpy(Taskstring+h,byte,1);
}

char* partly_string = new char[length]
memset(partly_string, '\0', length+1);

//nun das teilweise auslesen
for (int alpha=1;alpha &lt; length ;alpha++){
 partly_string[alpha]=Taskstring[alpha];
}
</code></pre>
<p>Das Problem ist das er keine werte in den partly_string schreibt. Beim Debuggen sind aber die Zeichen bei Taskstring[alpha] zu sehen.<br />
Es Klappt nur wenn ich mit alpha bei 0 starte. Ich will aber zb. das erste Zeichen wegcutten. Aber das chararray bleibt leider leer.<br />
Hat vielleicht einer einen hinweis. Hab auch schon mit memset, memcpy versucht die chars zu füllen. Geht aber alles nur wenn ich wie gesagt bei 0 den counter starte. danke für hilfe</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/270232/auslesen-von-chars-schlägt-fehl</link><generator>RSS for Node</generator><lastBuildDate>Sun, 30 Aug 2026 12:51:32 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/270232.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 08 Jul 2010 16:24:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to auslesen von chars schlägt fehl. on Thu, 08 Jul 2010 16:24:52 GMT]]></title><description><![CDATA[<p>Hallo habe ein chararray aus dem ein teil der chars auslesen und in ein neues chararray packen will.</p>
<pre><code>//fill origin string geht ohne probleme
char *Taskstring = new char[length+1];
memset(Taskstring, '\0', length+1);
char byte[1];
for (int h=0; h &lt; length ;h++){
 byte[0] = file.readUint8();
 strncpy(Taskstring+h,byte,1);
}

char* partly_string = new char[length]
memset(partly_string, '\0', length+1);

//nun das teilweise auslesen
for (int alpha=1;alpha &lt; length ;alpha++){
 partly_string[alpha]=Taskstring[alpha];
}
</code></pre>
<p>Das Problem ist das er keine werte in den partly_string schreibt. Beim Debuggen sind aber die Zeichen bei Taskstring[alpha] zu sehen.<br />
Es Klappt nur wenn ich mit alpha bei 0 starte. Ich will aber zb. das erste Zeichen wegcutten. Aber das chararray bleibt leider leer.<br />
Hat vielleicht einer einen hinweis. Hab auch schon mit memset, memcpy versucht die chars zu füllen. Geht aber alles nur wenn ich wie gesagt bei 0 den counter starte. danke für hilfe</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1923401</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1923401</guid><dc:creator><![CDATA[greenghecco]]></dc:creator><pubDate>Thu, 08 Jul 2010 16:24:52 GMT</pubDate></item><item><title><![CDATA[Reply to auslesen von chars schlägt fehl. on Thu, 08 Jul 2010 16:37:39 GMT]]></title><description><![CDATA[<p>Vergiss alles mit memcpy, memset, strncpy &amp; Co. Am besten auch char-Arrays. Da bist du anscheinend an eine Anleitung für C geraten (die in C++ wegen Abwärtskompatibilität auch funktioniert). Aber in C++ geht das alles wesentlich einfacher. Such mal auf <a href="http://www.cplusplus.com/" rel="nofollow">dieser Seite</a> nach den folgenden Stichworten:<br />
copy, string, vector, fill</p>
<p>Damit sollte das eigentlich ziemlich leicht sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1923410</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1923410</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Thu, 08 Jul 2010 16:37:39 GMT</pubDate></item><item><title><![CDATA[Reply to auslesen von chars schlägt fehl. on Thu, 08 Jul 2010 17:17:53 GMT]]></title><description><![CDATA[<p>naja gut aber am ende muss es leider für das system was ich nutze chararrays sein</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1923435</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1923435</guid><dc:creator><![CDATA[greenghecco]]></dc:creator><pubDate>Thu, 08 Jul 2010 17:17:53 GMT</pubDate></item><item><title><![CDATA[Reply to auslesen von chars schlägt fehl. on Thu, 08 Jul 2010 17:32:38 GMT]]></title><description><![CDATA[<p>Dann verwendest du am Ende <a href="http://www.cplusplus.com/reference/string/string/c_str/" rel="nofollow">c_str</a>.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1923448</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1923448</guid><dc:creator><![CDATA[Athar]]></dc:creator><pubDate>Thu, 08 Jul 2010 17:32:38 GMT</pubDate></item><item><title><![CDATA[Reply to auslesen von chars schlägt fehl. on Thu, 08 Jul 2010 19:33:32 GMT]]></title><description><![CDATA[<p>schon dabei ;).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1923533</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1923533</guid><dc:creator><![CDATA[greenghecco]]></dc:creator><pubDate>Thu, 08 Jul 2010 19:33:32 GMT</pubDate></item></channel></rss>