<?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[Mehrdeutige Operatoren, hash Map usw.]]></title><description><![CDATA[<p>Hallo Zusammen,</p>
<p>leider hänge ich bei dem Code an ein Paar Stellen. Die Klasse soll es möglich machen eine Datei zu öffnen und von dort den Text zu IDs auszulesen. Dadurch soll es möglichst einfach sein, dem Programm mehrere Sprachen beizubringen. Die Textdatei muss Unicode-Zeichen aufnehmen.<br />
Die Datei hat Format:<br />
ID_XXX=textsoundso<br />
ID_YYY=textblabla</p>
<p>Mein Problem ist jetzt, dass ich in Zeilen 79(&quot;==&quot;), 94 und 95 (jeweils &quot;=&quot;) mehrdeutige Operatoren vom Kompiler als Fehler bekomm. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /> Ich habe auch schon unterschiedliche Castings probiert (vielleicht nur falsch???), ohne Erfolg. Desweiteren würde ich gerne das Array, in dem ich die IDs und den Text speicher als hashmap realisieren. Ich habe zu Hash Map keine geeignete Anleitung auf Deutsch gefunden.</p>
<p>Allgemeine Tipps sind natürlich auch willkommen. Schließlich will ich ja etwas lernen <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>
<p>Vielen Dank im Voraus für Eure Mühe.</p>
<pre><code class="language-cpp">#include &quot;stdafx.h&quot;
#include &quot;cstring&quot;
#include &quot;Test2.h&quot;

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

#ifndef _UNICODE
#define _UNICODE
#endif

CWinApp theApp;
using namespace std;

class TxtToID
{
	public:

		CString filename;
		CFile tempFile;
		CString tempString;
		int tempInt;
		int buffsize;
		bool hresult;

		TxtToID();
		~TxtToID();
		int FileOpen(CString filename);
		int FileClose(CString filename);
		CString GetLang();
		CString ReadLine(CString filename, int buffsize);
		CString GetTextForID(CString ID);
		CString TxtToID::CreateIDTxtArray(CString filename, int buffsize);
};

int TxtToID::FileOpen(CString filename)
{	
	tempFile.Open(filename, CFile::modeRead);
	return 0;
}

int TxtToID::FileClose(CString filename)
{
	tempFile.Close();
	return 0;
}

CString TxtToID::GetLang()
{
	CString Sprache, tempString;
	TxtToID TEMP;
	filename = &quot;conf.ini&quot;;
	buffsize = 50;

	TEMP.FileOpen(filename);

	CStdioFile tempCStdioFile;
	tempString = TEMP.ReadLine(filename, buffsize);

	while (tempString != &quot;[Systemlanguage]&quot;)
	{tempString = TEMP.ReadLine(filename, buffsize);}
	tempString = TEMP.ReadLine(filename, buffsize);

	if (tempString.Find(_T(&quot;german&quot;), 0)) {filename = &quot;Properties_GER.txt&quot;;}
	else {filename = &quot;Properties_ENG.txt&quot;;}
	return filename;
}

CString TxtToID::ReadLine(CString filename, int buffsize)
{ 
	CStdioFile tempCStdioFile;
	hresult = true;
	tempString = tempCStdioFile.ReadString(filename.GetBuffer(buffsize), buffsize);
	filename.ReleaseBuffer();
	if (tempString == false) {hresult = false;}
	return tempString;
}

CString TxtToID::CreateIDTxtArray(CString filename, int buffsize)
{
	int n = 0;
	CString ID;
	CString IDTextArray[2][500];
	FileOpen(filename);
	while(hresult)
	{
		IDTextArray[0][n] = ReadLine(filename, buffsize);
		tempInt = tempString.Find('=', 0);
		tempString = tempString.Right(tempInt);
		IDTextArray[1][n] = tempString.Delete(0);
		IDTextArray[0][n] = IDTextArray[0][n] - tempString;
		n++;
	}
	return ID;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/164212/mehrdeutige-operatoren-hash-map-usw</link><generator>RSS for Node</generator><lastBuildDate>Thu, 30 Jul 2026 18:05:01 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/164212.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 06 Nov 2006 09:33:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Mehrdeutige Operatoren, hash Map usw. on Mon, 06 Nov 2006 09:33:52 GMT]]></title><description><![CDATA[<p>Hallo Zusammen,</p>
<p>leider hänge ich bei dem Code an ein Paar Stellen. Die Klasse soll es möglich machen eine Datei zu öffnen und von dort den Text zu IDs auszulesen. Dadurch soll es möglichst einfach sein, dem Programm mehrere Sprachen beizubringen. Die Textdatei muss Unicode-Zeichen aufnehmen.<br />
Die Datei hat Format:<br />
ID_XXX=textsoundso<br />
ID_YYY=textblabla</p>
<p>Mein Problem ist jetzt, dass ich in Zeilen 79(&quot;==&quot;), 94 und 95 (jeweils &quot;=&quot;) mehrdeutige Operatoren vom Kompiler als Fehler bekomm. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /> Ich habe auch schon unterschiedliche Castings probiert (vielleicht nur falsch???), ohne Erfolg. Desweiteren würde ich gerne das Array, in dem ich die IDs und den Text speicher als hashmap realisieren. Ich habe zu Hash Map keine geeignete Anleitung auf Deutsch gefunden.</p>
<p>Allgemeine Tipps sind natürlich auch willkommen. Schließlich will ich ja etwas lernen <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>
<p>Vielen Dank im Voraus für Eure Mühe.</p>
<pre><code class="language-cpp">#include &quot;stdafx.h&quot;
#include &quot;cstring&quot;
#include &quot;Test2.h&quot;

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

#ifndef _UNICODE
#define _UNICODE
#endif

CWinApp theApp;
using namespace std;

class TxtToID
{
	public:

		CString filename;
		CFile tempFile;
		CString tempString;
		int tempInt;
		int buffsize;
		bool hresult;

		TxtToID();
		~TxtToID();
		int FileOpen(CString filename);
		int FileClose(CString filename);
		CString GetLang();
		CString ReadLine(CString filename, int buffsize);
		CString GetTextForID(CString ID);
		CString TxtToID::CreateIDTxtArray(CString filename, int buffsize);
};

int TxtToID::FileOpen(CString filename)
{	
	tempFile.Open(filename, CFile::modeRead);
	return 0;
}

int TxtToID::FileClose(CString filename)
{
	tempFile.Close();
	return 0;
}

CString TxtToID::GetLang()
{
	CString Sprache, tempString;
	TxtToID TEMP;
	filename = &quot;conf.ini&quot;;
	buffsize = 50;

	TEMP.FileOpen(filename);

	CStdioFile tempCStdioFile;
	tempString = TEMP.ReadLine(filename, buffsize);

	while (tempString != &quot;[Systemlanguage]&quot;)
	{tempString = TEMP.ReadLine(filename, buffsize);}
	tempString = TEMP.ReadLine(filename, buffsize);

	if (tempString.Find(_T(&quot;german&quot;), 0)) {filename = &quot;Properties_GER.txt&quot;;}
	else {filename = &quot;Properties_ENG.txt&quot;;}
	return filename;
}

CString TxtToID::ReadLine(CString filename, int buffsize)
{ 
	CStdioFile tempCStdioFile;
	hresult = true;
	tempString = tempCStdioFile.ReadString(filename.GetBuffer(buffsize), buffsize);
	filename.ReleaseBuffer();
	if (tempString == false) {hresult = false;}
	return tempString;
}

CString TxtToID::CreateIDTxtArray(CString filename, int buffsize)
{
	int n = 0;
	CString ID;
	CString IDTextArray[2][500];
	FileOpen(filename);
	while(hresult)
	{
		IDTextArray[0][n] = ReadLine(filename, buffsize);
		tempInt = tempString.Find('=', 0);
		tempString = tempString.Right(tempInt);
		IDTextArray[1][n] = tempString.Delete(0);
		IDTextArray[0][n] = IDTextArray[0][n] - tempString;
		n++;
	}
	return ID;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1169434</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1169434</guid><dc:creator><![CDATA[Sexymaxy]]></dc:creator><pubDate>Mon, 06 Nov 2006 09:33:52 GMT</pubDate></item><item><title><![CDATA[Reply to Mehrdeutige Operatoren, hash Map usw. on Mon, 06 Nov 2006 09:49:15 GMT]]></title><description><![CDATA[<p>Sexymaxy schrieb:</p>
<blockquote>
<p>Mein Problem ist jetzt, dass ich in Zeilen 79(&quot;==&quot;), 94 und 95 (jeweils &quot;=&quot;) mehrdeutige Operatoren vom Kompiler als Fehler bekomm.</p>
</blockquote>
<p>Klar, wenn du einen CString mit einem bool vergleichst (an der Stelle wäre wohl <code>tempstring == &quot;&quot;</code> passender) bzw. einen int-Wert zuweisen willst (versuch'S mal mit <code>IDTextArray[1][n] = tempString.Mid(1);</code> bzw. (keine Ahnung, was du mit Zeile 95 vorhast)).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1169445</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1169445</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 06 Nov 2006 09:49:15 GMT</pubDate></item><item><title><![CDATA[Reply to Mehrdeutige Operatoren, hash Map usw. on Mon, 06 Nov 2006 10:02:38 GMT]]></title><description><![CDATA[<p>Das ReadString liefert einen Bool, ob das einlesen der Zeile richtig ist. Ich habe es dann falsch interpretiert. Danke an dieser Stelle. <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="🙂"
    /> Mit der Zeile 95 möchte ich aus dem ID_XXX=Text das &quot;=Text&quot; abschneiden, so dass ich in [0][n] immer die ID und in [1][n] den Text stehen hab.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1169455</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1169455</guid><dc:creator><![CDATA[Sexymaxy]]></dc:creator><pubDate>Mon, 06 Nov 2006 10:02:38 GMT</pubDate></item><item><title><![CDATA[Reply to Mehrdeutige Operatoren, hash Map usw. on Mon, 06 Nov 2006 10:23:10 GMT]]></title><description><![CDATA[<p>Erstmal solltest du die ganzen temp... Variablen nur dort deklarieren, wo du sie auch brauchst. (statt über (semi)globale Variablen Daten auszutauschen, nutz lieber Parameter und Rückgabewerte)<br />
Auf der anderen Seite solltest du das Array &quot;IDTextArray&quot; als Member deiner Klasse anlegen, dann brauchst du es nur einmal einzulesen und anschließen nur noch darin zu suchen.</p>
<p>Und zweitens ist die Zerlegung von Strings etwas komplizierter (da gibt es keinen op-, deshalb wandelt der Compiler beide Strings in char* um und berechnet die Zeiger-Differenz):</p>
<pre><code class="language-cpp">tempstring = ReadLine(...);
pos = tempstring.Find(&quot;=&quot;);
IDArray[0][n]=tempstring.Left(pos-1);
IDArray[1][n]=tempstring.Mid(pos+1);
</code></pre>
<p>PS: Drittens ist die ganze Berechnung in der CreateIDTextArray() sinnlos, weil das Text-Array am Ende sofort wieder gelöscht wird und ID während der Berechnung nicht angefasst wurde.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1169466</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1169466</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 06 Nov 2006 10:23:10 GMT</pubDate></item><item><title><![CDATA[Reply to Mehrdeutige Operatoren, hash Map usw. on Mon, 06 Nov 2006 14:16:14 GMT]]></title><description><![CDATA[<p>Vielen Dank. Jetzt funktionierts, wie gewünscht. Jetzt bleibt nur noch die Frage, wie ich am besten statt Arry Hash Map verwende.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1169674</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1169674</guid><dc:creator><![CDATA[Sexymaxy]]></dc:creator><pubDate>Mon, 06 Nov 2006 14:16:14 GMT</pubDate></item><item><title><![CDATA[Reply to Mehrdeutige Operatoren, hash Map usw. on Mon, 06 Nov 2006 17:52:55 GMT]]></title><description><![CDATA[<p>Nimm doch einfach die map aus der STL. Oder meintest Du was anderes?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1169900</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1169900</guid><dc:creator><![CDATA[connan]]></dc:creator><pubDate>Mon, 06 Nov 2006 17:52:55 GMT</pubDate></item></channel></rss>