<?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[strings in textdatei schreiben]]></title><description><![CDATA[<p>hallo,</p>
<p>meine Software erstellt eine Log-file in dem alle ausgeführten Funktionen archiviert werden. Hierzu verwende ich den folgenden Code:</p>
<pre><code class="language-cpp">void CError::Wr2LogFile(CString szActualRuntimeFunction)
{
	FILE* Stream;
	LPSTR pstrActualFunction = szActualRuntimeFunction.GetBuffer(0);
	Uint8_t nLength = szActualRuntimeFunction.GetLength();

         if((Stream = fopen(&quot;Logg.txt&quot;, &quot;a&quot;)) != NULL)
	{
		fwrite(pstrActualFunction, nLength, 50, Stream);
	}
	fclose(Stream);
}
</code></pre>
<p>In der Datei ist schließlich nur der zuletzt geschriebene String aufzufinden, auf ihn folgen dann nur noch &quot;kryptische&quot; Zeichen. Wer kennt sich hiermit aus, und kann mir weiterhelfen?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/194566/strings-in-textdatei-schreiben</link><generator>RSS for Node</generator><lastBuildDate>Tue, 29 Sep 2026 15:56:47 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/194566.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 08 Oct 2007 14:15:19 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to strings in textdatei schreiben on Mon, 08 Oct 2007 14:15:19 GMT]]></title><description><![CDATA[<p>hallo,</p>
<p>meine Software erstellt eine Log-file in dem alle ausgeführten Funktionen archiviert werden. Hierzu verwende ich den folgenden Code:</p>
<pre><code class="language-cpp">void CError::Wr2LogFile(CString szActualRuntimeFunction)
{
	FILE* Stream;
	LPSTR pstrActualFunction = szActualRuntimeFunction.GetBuffer(0);
	Uint8_t nLength = szActualRuntimeFunction.GetLength();

         if((Stream = fopen(&quot;Logg.txt&quot;, &quot;a&quot;)) != NULL)
	{
		fwrite(pstrActualFunction, nLength, 50, Stream);
	}
	fclose(Stream);
}
</code></pre>
<p>In der Datei ist schließlich nur der zuletzt geschriebene String aufzufinden, auf ihn folgen dann nur noch &quot;kryptische&quot; Zeichen. Wer kennt sich hiermit aus, und kann mir weiterhelfen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1380526</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1380526</guid><dc:creator><![CDATA[maRKus23]]></dc:creator><pubDate>Mon, 08 Oct 2007 14:15:19 GMT</pubDate></item><item><title><![CDATA[Reply to strings in textdatei schreiben on Mon, 08 Oct 2007 14:18:55 GMT]]></title><description><![CDATA[<blockquote>
<p>size_t fwrite ( const void * ptr, size_t size, size_t count, FILE * stream );</p>
<p>&lt;cstdio&gt;</p>
<p>Write block of data to stream</p>
<p>Writes an array of count elements, each one with a size of size bytes, from the block of memory pointed by ptr to the current position in the stream.<br />
The postion indicator of the stream is advanced by the total amount of bytes written.<br />
The total amount of bytes written is (size * count).</p>
<p>Parameters</p>
<p>ptr<br />
Pointer to the array of elements to be written.<br />
size<br />
Size in bytes of each element to be written.<br />
count<br />
Number of elements, each one with a size of size bytes.<br />
stream<br />
Pointer to a FILE object that specifies an output stream.</p>
</blockquote>
<p>size und count sind bei dir falsch</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1380534</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1380534</guid><dc:creator><![CDATA[gfd]]></dc:creator><pubDate>Mon, 08 Oct 2007 14:18:55 GMT</pubDate></item><item><title><![CDATA[Reply to strings in textdatei schreiben on Mon, 08 Oct 2007 14:20:54 GMT]]></title><description><![CDATA[<p>und was ist daran falsch?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1380536</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1380536</guid><dc:creator><![CDATA[maRKus23]]></dc:creator><pubDate>Mon, 08 Oct 2007 14:20:54 GMT</pubDate></item><item><title><![CDATA[Reply to strings in textdatei schreiben on Mon, 08 Oct 2007 14:23:25 GMT]]></title><description><![CDATA[<p>Du versuchst das fünfzigfache der Daten zu schreiben, die eigentlich im String stehen. (woher hast du diese '50' denn überhaupt?)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1380537</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1380537</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 08 Oct 2007 14:23:25 GMT</pubDate></item><item><title><![CDATA[Reply to strings in textdatei schreiben on Mon, 08 Oct 2007 14:25:25 GMT]]></title><description><![CDATA[<p>ahh, okay ich verstehe! Dachte damit wäre die maximale Anzahl der zu schreibenden Bytes gemeint.<br />
Noch eine Frage wie mache ich carriage return oder line feed?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1380539</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1380539</guid><dc:creator><![CDATA[maRKus23]]></dc:creator><pubDate>Mon, 08 Oct 2007 14:25:25 GMT</pubDate></item><item><title><![CDATA[Reply to strings in textdatei schreiben on Mon, 08 Oct 2007 14:32:32 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">fwrite(pstrActualFunction, nLength, 50, Stream);
</code></pre>
<p>sollte</p>
<pre><code class="language-cpp">fwrite(pstrActualFunction, sizeof(pstrActualFunction[0]), nLength, Stream);
</code></pre>
<p>heissen.</p>
<p>Im Momment ist dein String den du schreibt nämlich immer 50*nLength zeichen lang.</p>
<p>// Edit:</p>
<p>Da war ich wohl zu langsam. Zu Newline/CarriageReturn:</p>
<p>Ein newline machst du mit &quot;\n&quot;.<br />
Die C-Library konvertiert automatisch &quot;\n&quot; zu &quot;\r\n&quot;, also CarriageReturn + Newline wenn du dein Programm unter Windows kompilierst. Außer die Datei ist als Binärdatei geöffnet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1380541</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1380541</guid><dc:creator><![CDATA[TheRightWay]]></dc:creator><pubDate>Mon, 08 Oct 2007 14:32:32 GMT</pubDate></item><item><title><![CDATA[Reply to strings in textdatei schreiben on Mon, 08 Oct 2007 14:30:55 GMT]]></title><description><![CDATA[<p>maRKus23 schrieb:</p>
<blockquote>
<p>Noch eine Frage wie mache ich carriage return oder line feed?</p>
</blockquote>
<p>Das sind ganz normale Zeichen und werden als '\n' bzw. '\r' im Quelltext geschrieben (welcher was ist, bringe ich immer durcheinander - aber normalerweise wird ein einfaches \n in die OS-spezifisch richtige \r\n-Kombination umgerechnet)</p>
<p>PS: Für die Ausgabe von Strings solltest du besser fputs() verwenden - oder gleich die C++ IO-Streams.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1380543</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1380543</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 08 Oct 2007 14:30:55 GMT</pubDate></item></channel></rss>