<?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[Seltsame Sonderzeichen?]]></title><description><![CDATA[<pre><code class="language-cpp">void WriteLineNumbers(HWND hwnd, HWND hTarget)
{
	int numLines = GetLineCount(hwnd);
	char *tmp = new char[strlen(WindowText(hTarget))+5+2];
	for(int i = 0;i&lt;=numLines;++i)
	{
		char *ic = new char[sizeof(i)];
		itoa(i,ic,10);
		char *ret = new char[strlen(CombinChars(CombinChars(WindowText(hTarget),ic),&quot;\r\n&quot;))];
		ZeroMemory(ret,sizeof(ret));
		ret = CombinChars(WindowText(hTarget),ic);
		ret = CombinChars(ret,&quot;\r\n&quot;);
		SetWindowText(hTarget,ret);
	}
}
</code></pre>
<p>damit schreibe ich die zeilennummern in ein fenster...das problem ist, dass ich vor der &quot;8&quot; immer ein &quot;!&quot; habe. Auch bei anderen zeilen schleichen sich jedoch immer wieder seltsame sonderzeichen ein! Könnt ihr mir vielleicht sagen wie ich das verhindere bzw woran es liegt?</p>
<p>edit:problem gelößt...</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/78136/seltsame-sonderzeichen</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Apr 2026 04:14:26 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/78136.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 28 Jun 2004 12:54:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Seltsame Sonderzeichen? on Mon, 28 Jun 2004 12:59:15 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">void WriteLineNumbers(HWND hwnd, HWND hTarget)
{
	int numLines = GetLineCount(hwnd);
	char *tmp = new char[strlen(WindowText(hTarget))+5+2];
	for(int i = 0;i&lt;=numLines;++i)
	{
		char *ic = new char[sizeof(i)];
		itoa(i,ic,10);
		char *ret = new char[strlen(CombinChars(CombinChars(WindowText(hTarget),ic),&quot;\r\n&quot;))];
		ZeroMemory(ret,sizeof(ret));
		ret = CombinChars(WindowText(hTarget),ic);
		ret = CombinChars(ret,&quot;\r\n&quot;);
		SetWindowText(hTarget,ret);
	}
}
</code></pre>
<p>damit schreibe ich die zeilennummern in ein fenster...das problem ist, dass ich vor der &quot;8&quot; immer ein &quot;!&quot; habe. Auch bei anderen zeilen schleichen sich jedoch immer wieder seltsame sonderzeichen ein! Könnt ihr mir vielleicht sagen wie ich das verhindere bzw woran es liegt?</p>
<p>edit:problem gelößt...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/549285</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/549285</guid><dc:creator><![CDATA[pixartist]]></dc:creator><pubDate>Mon, 28 Jun 2004 12:59:15 GMT</pubDate></item><item><title><![CDATA[Reply to Seltsame Sonderzeichen? on Mon, 28 Jun 2004 16:43:22 GMT]]></title><description><![CDATA[<blockquote>
<p>edit:problem gelößt...</p>
</blockquote>
<p>die speicherlecks auch?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/549441</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/549441</guid><dc:creator><![CDATA[CMatt]]></dc:creator><pubDate>Mon, 28 Jun 2004 16:43:22 GMT</pubDate></item><item><title><![CDATA[Reply to Seltsame Sonderzeichen? on Mon, 28 Jun 2004 20:52:06 GMT]]></title><description><![CDATA[<p>speicherlecks?<br />
ic hat jetzt ne konstnate länge von 5...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/549595</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/549595</guid><dc:creator><![CDATA[pixartist]]></dc:creator><pubDate>Mon, 28 Jun 2004 20:52:06 GMT</pubDate></item><item><title><![CDATA[Reply to Seltsame Sonderzeichen? on Tue, 29 Jun 2004 06:06:36 GMT]]></title><description><![CDATA[<p>pixartist schrieb:</p>
<blockquote>
<p>speicherlecks?</p>
</blockquote>
<p>Ich wußte das er das sagen würde... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/549662</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/549662</guid><dc:creator><![CDATA[Hepi]]></dc:creator><pubDate>Tue, 29 Jun 2004 06:06:36 GMT</pubDate></item><item><title><![CDATA[Reply to Seltsame Sonderzeichen? on Tue, 29 Jun 2004 07:01:01 GMT]]></title><description><![CDATA[<p>jedes new braucht ein delete<br />
<a href="http://tutorial.schornboeck.net/dyn_speicher.htm" rel="nofollow">http://tutorial.schornboeck.net/dyn_speicher.htm</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/549675</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/549675</guid><dc:creator><![CDATA[miller_m]]></dc:creator><pubDate>Tue, 29 Jun 2004 07:01:01 GMT</pubDate></item><item><title><![CDATA[Reply to Seltsame Sonderzeichen? on Tue, 29 Jun 2004 12:15:41 GMT]]></title><description><![CDATA[<p>wieso stürtzt das jetzt ab?</p>
<pre><code class="language-cpp">char *CombinChars(char *char1, char *char2)
{
	char *tmp = new char[strlen(char1)+strlen(char2)];
	ZeroMemory(tmp,strlen(char1)+strlen(char2));
	for(int i=0;i&lt;=strlen(char1);++i)
	{
		tmp[i] = char1[i];
	}
	for(int x=0;x&lt;=strlen(char2);++x)
	{
		tmp[x+strlen(char1)] = char2[x];
	}
	return tmp;
}
</code></pre>
<p>...</p>
<pre><code class="language-cpp">void WriteLineNumbers(HWND hwnd, HWND hTarget, int oldLineCount)
{
	int ToChange = oldLineCount-GetLineCount(hwnd);
	if(ToChange != 0)
	{
		char *winText;
		winText = &quot;&quot;;
		SetWindowText(hTarget,winText);
		int numLines = GetLineCount(hwnd);
		char *ic = new char[5];
		if(numLines&gt;99999)
		{
			PostQuitMessage (0);
		}
		for(int i = 0;i&lt;=numLines;++i)
		{
			itoa(i,ic,10);
			//char *ret = new char[strlen(CombinChars(CombinChars(WindowText(hTarget),ic),&quot;\r\n&quot;))];
			char *ret = new char[i*9];
			ret = CombinChars(winText,ic);
			ret = CombinChars(ret,&quot;\r\n&quot;);
			delete [] winText;
			winText = new char[strlen(ret)];
			winText = ret;
		}
		SetWindowText(hTarget,winText);
	}	
	ScrollToSamePos(hwnd,hTarget);
}
</code></pre>
<p>edit und habt ihr ne idee wie ich an die charlänge von ic und somit auch von ret komme?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/549756</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/549756</guid><dc:creator><![CDATA[pixartist]]></dc:creator><pubDate>Tue, 29 Jun 2004 12:15:41 GMT</pubDate></item><item><title><![CDATA[Reply to Seltsame Sonderzeichen? on Tue, 29 Jun 2004 12:15:03 GMT]]></title><description><![CDATA[<p>strlen liefert nur die Anzahl der Zeichen ohne Null-Terminierung!<br />
x&lt;=strlen(char2) sagt mir das du die Null-Terminierung mitkopierst aber du scheinst dafür gar keinen Speicher reserviert zu haben...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/549763</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/549763</guid><dc:creator><![CDATA[geeky]]></dc:creator><pubDate>Tue, 29 Jun 2004 12:15:03 GMT</pubDate></item><item><title><![CDATA[Reply to Seltsame Sonderzeichen? on Tue, 29 Jun 2004 12:16:58 GMT]]></title><description><![CDATA[<p>was? und wie mache ich ne null-terminierung? ^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/549767</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/549767</guid><dc:creator><![CDATA[pixartist]]></dc:creator><pubDate>Tue, 29 Jun 2004 12:16:58 GMT</pubDate></item><item><title><![CDATA[Reply to Seltsame Sonderzeichen? on Tue, 29 Jun 2004 12:38:26 GMT]]></title><description><![CDATA[<p>Sagen wir mal char1 sähe so aus:<br />
char1[0]='T';<br />
char1[1]='e';<br />
char1[2]='s';<br />
char1[3]='t';<br />
char1[4]='\0'; // Null-Terminierung. Wenns strlen dieses Zeichen findet, weiss es<br />
dass der String zu ende ist.</p>
<p>und char2 so:<br />
char2[0]='b';<br />
char2[1]='l';<br />
char2[2]='a';<br />
char2[3]='\0';</p>
<p>strlen(char1) liefert 4 und strlen(char2) liefert 3</p>
<p>Jetzt reservierst du für tmp 7 Byte an Speicher.<br />
Und kopierst die zeichen 0 bis 4, also char1[0] bis char1[4] in tmp:</p>
<p>tmp[0]='t'; // 1. Byte<br />
tmp[1]='e'; // 2. Byte<br />
tmp[2]='s'; // 3. Byte<br />
tmp[3]='t'; // 4. Byte<br />
tmp[4]='\0'; // 5. Byte<br />
tmp[5]=irgendnenWert; // 6. Byte<br />
tmp[6]=irgendnenWert; // 7. Byte</p>
<p>Jetzt willst du string2 scheinbar drankopieren:<br />
tmp[x+strlen(char1)] wäre also tmp[0+4] also wiederrum tmp[4]<br />
Du überschreibst also zuerst einmal die mitkopierte Nullterminierung.<br />
und kopierst jetzt von tmp[4] bis tmp[strlen(char2)+strlen(char1)] quasi char2 darein.</p>
<p>tmp[strlen(char2)+strlen(char1)] wäre tmp[3+4], also tmp[7]</p>
<p>Nun hast du nur Speicher für maximal tmp[6] (tmp[0] bis tmp[6] sind 7 Bytes) reserviert, dir fehlt ein Byte (tmp[0] bis tmp[7] wären 8 Byte).<br />
Du kopierst also über den reservierten Speicher hinaus was unter Umständen eine Speicherverletzung gibt.</p>
<p>Du musst also nur 1 Byte mehr Speicher reservieren für die letzte Null-Terminierung.<br />
Du könntest dir die for-Schleifen sparen und stattdessen memcpy() benutzen...<br />
Du könntest auch strcpy() und strcat() benutzen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/549789</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/549789</guid><dc:creator><![CDATA[geeky]]></dc:creator><pubDate>Tue, 29 Jun 2004 12:38:26 GMT</pubDate></item><item><title><![CDATA[Reply to Seltsame Sonderzeichen? on Tue, 29 Jun 2004 12:37:08 GMT]]></title><description><![CDATA[<p><a href="http://www.c-plusplus.net/tutorials.htm" rel="nofollow">http://www.c-plusplus.net/tutorials.htm</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/549790</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/549790</guid><dc:creator><![CDATA[Hepi]]></dc:creator><pubDate>Tue, 29 Jun 2004 12:37:08 GMT</pubDate></item><item><title><![CDATA[Reply to Seltsame Sonderzeichen? on Tue, 29 Jun 2004 13:53:57 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">char *CombinChars(char *char1, char *char2)
{
	char *tmp = new char[strlen(char1)+strlen(char2)+1];
//---------------------------------&gt;tmp nicht nullterminiert ^^
	memcpy(tmp,char1,strlen(char1));
	memcpy(tmp+strlen(char1),char2,strlen(char2));
	/*for(int i=0;i&lt;=strlen(char1);++i)
	{
		tmp[i] = char1[i];
	}
	for(int x=0;x&lt;=strlen(char2);++x)
	{
		tmp[x+strlen(char1)] = char2[x];
	}*/
	return tmp;
}
</code></pre>
<pre><code class="language-cpp">void WriteLineNumbers(HWND hwnd, HWND hTarget, int oldLineCount)
{
	int ToChange = oldLineCount-GetLineCount(hwnd);
	if(ToChange != 0)
	{
		char *winText;
		winText = &quot;&quot;;
		SetWindowText(hTarget,winText);
		int numLines = GetLineCount(hwnd);
		char *ic = new char[5];
		ic[5] = '\0';
		if(numLines&gt;99999)
		{
			PostQuitMessage (0);
		}
		for(int i = 0;i&lt;=numLines;++i)
		{
			itoa(i,ic,10);
			//char *ret = new char[strlen(CombinChars(CombinChars(WindowText(hTarget),ic),&quot;\r\n&quot;))];
			char *ret = new char[(i)*9];
			ret[(i*9)] = '\0';
			winText[strlen(winText)] = '\0';
			ret = CombinChars(winText,ic);
			ret = CombinChars(ret,&quot;\r\n&quot;);
			delete [] winText;
			winText = new char[strlen(ret)];
			winText[strlen(ret)] = '\0';
			winText = ret;
		}
		SetWindowText(hTarget,winText);
	}	
	ScrollToSamePos(hwnd,hTarget);
}
</code></pre>
<p>stürtzt immernoch ab oO</p>
<p>btw muss ich so nullterminieren:<br />
ret[(i<em>9)] = '\0';<br />
oder so:<br />
ret[(i</em>9)-1] = '\0';<br />
bei ersten schreibe ich ja im grunde über die länge raus und bei zweiten schneide ich den letzten char ab ...</p>
<p>edit: ich glaube jetzt stürtzt es nichtmehr ab:</p>
<pre><code class="language-cpp">void WriteLineNumbers(HWND hwnd, HWND hTarget, int oldLineCount)
{
	int ToChange = oldLineCount-GetLineCount(hwnd);
	if(ToChange != 0)
	{
		char *winText;
		winText = &quot;&quot;;
		SetWindowText(hTarget,winText);
		int numLines = GetLineCount(hwnd);
		char *ic = new char[6];
		ic[5] = '\0';
		if(numLines&gt;99999)
		{
			PostQuitMessage (0);
		}
		for(int i = 0;i&lt;=numLines;++i)
		{
			itoa(i,ic,10);
			//char *ret = new char[strlen(CombinChars(CombinChars(WindowText(hTarget),ic),&quot;\r\n&quot;))];
			char *ret = new char[(i*9)+1];
			ret[(i*9)] = '\0';
			winText[strlen(winText)] = '\0';
			ret = CombinChars(winText,ic);
			ret = CombinChars(ret,&quot;\r\n&quot;);
			delete [] winText;
			winText = new char[strlen(ret)+1];
			winText = ret;
		}
		SetWindowText(hTarget,winText);
	}	
	ScrollToSamePos(hwnd,hTarget);
}
</code></pre>
<p>dafür hab ich jetzt nen andren bug...ich such mal den fehler ^^<br />
edit: also wenn ich die erste datei lade ist noch alles ok, aber wenn ich dann irgendwas ändere dann spacken die zahlen richtig ab <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>EDIT(mal wieder): habt ihr ne idee wie man die funktion schneller gestalten kann?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/549822</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/549822</guid><dc:creator><![CDATA[pixartist]]></dc:creator><pubDate>Tue, 29 Jun 2004 13:53:57 GMT</pubDate></item><item><title><![CDATA[Reply to Seltsame Sonderzeichen? on Tue, 29 Jun 2004 14:05:32 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/2053">@hepi</a><br />
du gibst es nicht auf. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/549843</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/549843</guid><dc:creator><![CDATA[miller_m]]></dc:creator><pubDate>Tue, 29 Jun 2004 14:05:32 GMT</pubDate></item><item><title><![CDATA[Reply to Seltsame Sonderzeichen? on Tue, 29 Jun 2004 14:58:24 GMT]]></title><description><![CDATA[<p>miller_m schrieb:</p>
<blockquote>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/2053">@hepi</a><br />
du gibst es nicht auf. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
</blockquote>
<p>Na, die fehlenden Grundlagen werden doch immer offensichtlicher... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/549874</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/549874</guid><dc:creator><![CDATA[Hepi]]></dc:creator><pubDate>Tue, 29 Jun 2004 14:58:24 GMT</pubDate></item></channel></rss>