<?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[Problem mit CFile::Read()]]></title><description><![CDATA[<p>Ich möchte eine XML-Datei öffnen und ausgeben.<br />
Funktioniert auch alles, nur erhalte ich bei der Ausgabe am Ende einige Sonderzeichen die nicht in der XML Datei stehen.</p>
<p>hier mein code:</p>
<pre><code class="language-cpp">TCHAR* CSocketGuiDlg::ReadXMLFile()
{		
	f.SeekToBegin();
	int fileSize = f.GetLength();
	TCHAR *str = new TCHAR[fileSize];
	f.Read(str, fileSize);
	return str;
}
</code></pre>
<p>und hier wird alles in ein Textfeld ausgegeben:</p>
<pre><code class="language-cpp">GetDlgItem(IDC_FILE)-&gt;SetWindowTextA(LPCTSTR(ReadXMLFile()));
</code></pre>
<p>die Ausgabe sieht so aus:</p>
<pre><code>&lt;addresses&gt;
   &lt;person&gt;
      &lt;name&gt;
         &lt;first&gt;Ingo&lt;/first&gt;
         &lt;last&gt;Melzer&lt;/last&gt;
      &lt;/name&gt;
      &lt;city&gt;Laupheim&lt;/city&gt;
      &lt;country&gt;Germany&lt;/country&gt;
   &lt;/person&gt;
   &lt;person&gt;
      &lt;name&gt;
         &lt;first&gt;Andreas F.&lt;/first&gt;
         &lt;last&gt;Borchert&lt;/last&gt;
      &lt;/name&gt;
      &lt;city&gt;Lonsee&lt;/city&gt;
      &lt;country&gt;Germany&lt;/country&gt;
   &lt;/person&gt;
&lt;/addresses&gt;
[b]ýýýý««««««««þîþîþ[/b]
</code></pre>
<p>Hab auch alles schon mal in einem Stream über einen Socket verschickt. Erhalte dann die gleiche Ausgabe. Also liegt es nicht an dem Textfeld in dem ich es ausgebe.<br />
Hat jemand Tipps für mich?!?</p>
<p>Danke!! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/189234/problem-mit-cfile-read</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Apr 2026 19:58:56 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/189234.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 10 Aug 2007 07:47:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem mit CFile::Read() on Fri, 10 Aug 2007 07:47:34 GMT]]></title><description><![CDATA[<p>Ich möchte eine XML-Datei öffnen und ausgeben.<br />
Funktioniert auch alles, nur erhalte ich bei der Ausgabe am Ende einige Sonderzeichen die nicht in der XML Datei stehen.</p>
<p>hier mein code:</p>
<pre><code class="language-cpp">TCHAR* CSocketGuiDlg::ReadXMLFile()
{		
	f.SeekToBegin();
	int fileSize = f.GetLength();
	TCHAR *str = new TCHAR[fileSize];
	f.Read(str, fileSize);
	return str;
}
</code></pre>
<p>und hier wird alles in ein Textfeld ausgegeben:</p>
<pre><code class="language-cpp">GetDlgItem(IDC_FILE)-&gt;SetWindowTextA(LPCTSTR(ReadXMLFile()));
</code></pre>
<p>die Ausgabe sieht so aus:</p>
<pre><code>&lt;addresses&gt;
   &lt;person&gt;
      &lt;name&gt;
         &lt;first&gt;Ingo&lt;/first&gt;
         &lt;last&gt;Melzer&lt;/last&gt;
      &lt;/name&gt;
      &lt;city&gt;Laupheim&lt;/city&gt;
      &lt;country&gt;Germany&lt;/country&gt;
   &lt;/person&gt;
   &lt;person&gt;
      &lt;name&gt;
         &lt;first&gt;Andreas F.&lt;/first&gt;
         &lt;last&gt;Borchert&lt;/last&gt;
      &lt;/name&gt;
      &lt;city&gt;Lonsee&lt;/city&gt;
      &lt;country&gt;Germany&lt;/country&gt;
   &lt;/person&gt;
&lt;/addresses&gt;
[b]ýýýý««««««««þîþîþ[/b]
</code></pre>
<p>Hab auch alles schon mal in einem Stream über einen Socket verschickt. Erhalte dann die gleiche Ausgabe. Also liegt es nicht an dem Textfeld in dem ich es ausgebe.<br />
Hat jemand Tipps für mich?!?</p>
<p>Danke!! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1341996</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1341996</guid><dc:creator><![CDATA[ben_]]></dc:creator><pubDate>Fri, 10 Aug 2007 07:47:34 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit CFile::Read() on Fri, 10 Aug 2007 07:54:01 GMT]]></title><description><![CDATA[<p>habs schon</p>
<pre><code class="language-cpp">TCHAR* CSocketGuiDlg::ReadXMLFile()
{       
    f.SeekToBegin();
    int fileSize = f.GetLength();
    TCHAR *str = new TCHAR[fileSize];
    f.Read(str, fileSize);
    str[fileSize]='\0';
    return str;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1341998</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1341998</guid><dc:creator><![CDATA[ben_]]></dc:creator><pubDate>Fri, 10 Aug 2007 07:54:01 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit CFile::Read() on Mon, 13 Aug 2007 06:52:09 GMT]]></title><description><![CDATA[<p>Und ich hoffe, dir ist klar, daß du gerade in fremdem Speicher rumschreibst. reservier dir lieber gleich ein zusätzliches Byte, um dort das \0 reinpacken zu können.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1343457</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1343457</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 13 Aug 2007 06:52:09 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit CFile::Read() on Mon, 13 Aug 2007 06:57:56 GMT]]></title><description><![CDATA[<p>Außerdem ist die Verwendung von TCHAR hier falsch, und der Cast auf LPCTSTR überflüssig.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1343462</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1343462</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Mon, 13 Aug 2007 06:57:56 GMT</pubDate></item></channel></rss>