<?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[Hilfe bei Variablen]]></title><description><![CDATA[<p>Hallo alle miteinnander!</p>
<p>Versuche momentan über mit Dev C++ eine Kartenlesegerät auszulesen und eine virtuelle Kaffeeliste zu erstellen.</p>
<p>Funktioniert momentan auch irgendwie (hab eigentlich keine Ahnung in Sachen Programmierung).</p>
<p>Da ich mir die Initialisierung der RS232-Schnittstelle sparen wollte (nutze XP), nutze ich Teraterm und lass die Daten vom Kartenlesegerat in eine .txt schreiben.</p>
<p>Emfange dort solche Daten:<br />
0414B7E73A<br />
0413B7F73A<br />
1214C7E74F<br />
0354A7E08C</p>
<p>Da ich nichts mit den Daten anfangen kann, die ich dort empfange, änder ich diese Daten von Hand über die Ersetzen-Funktion vom Notepad in einfache Variablen a,b,...</p>
<p>Gibt es nicht eine Möglichkeit z.B. den Datenblock &quot;0414B7E73A&quot; über C++ als Variable &quot;a&quot; zu definieren?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/264418/hilfe-bei-variablen</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Sep 2026 16:50:06 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/264418.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 07 Apr 2010 12:53:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Hilfe bei Variablen on Wed, 07 Apr 2010 12:53:49 GMT]]></title><description><![CDATA[<p>Hallo alle miteinnander!</p>
<p>Versuche momentan über mit Dev C++ eine Kartenlesegerät auszulesen und eine virtuelle Kaffeeliste zu erstellen.</p>
<p>Funktioniert momentan auch irgendwie (hab eigentlich keine Ahnung in Sachen Programmierung).</p>
<p>Da ich mir die Initialisierung der RS232-Schnittstelle sparen wollte (nutze XP), nutze ich Teraterm und lass die Daten vom Kartenlesegerat in eine .txt schreiben.</p>
<p>Emfange dort solche Daten:<br />
0414B7E73A<br />
0413B7F73A<br />
1214C7E74F<br />
0354A7E08C</p>
<p>Da ich nichts mit den Daten anfangen kann, die ich dort empfange, änder ich diese Daten von Hand über die Ersetzen-Funktion vom Notepad in einfache Variablen a,b,...</p>
<p>Gibt es nicht eine Möglichkeit z.B. den Datenblock &quot;0414B7E73A&quot; über C++ als Variable &quot;a&quot; zu definieren?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1878817</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1878817</guid><dc:creator><![CDATA[mechatroniker]]></dc:creator><pubDate>Wed, 07 Apr 2010 12:53:49 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe bei Variablen on Wed, 07 Apr 2010 12:57:39 GMT]]></title><description><![CDATA[<p><a href="http://www.cplusplus.com/reference/stl/map/" rel="nofollow">Map</a>?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1878823</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1878823</guid><dc:creator><![CDATA[freaky]]></dc:creator><pubDate>Wed, 07 Apr 2010 12:57:39 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe bei Variablen on Thu, 08 Apr 2010 07:37:55 GMT]]></title><description><![CDATA[<p>dannke erstmal für die schnelle Antwort.</p>
<p>Habe die Werte wie folgt definiert:</p>
<p>map &lt;string, string&gt; liste;<br />
liste [&quot;0414B7E73A&quot;] = [&quot;a&quot;]<br />
liste [&quot;0413B7F73A&quot;] = [&quot;b&quot;]<br />
liste [&quot;1214C7E74F&quot;] = [&quot;c&quot;]<br />
liste [&quot;0354A7E08C&quot;] = [&quot;d&quot;]</p>
<p>wenn ich nun die .txt zeilenweise auslese, wie kann ich dann z.B. &quot;0414B7E73A&quot; umschreiben zu &quot;a&quot;??</p>
<p>tia</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1879146</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1879146</guid><dc:creator><![CDATA[mechatroniker]]></dc:creator><pubDate>Thu, 08 Apr 2010 07:37:55 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe bei Variablen on Thu, 08 Apr 2010 07:48:29 GMT]]></title><description><![CDATA[<p>Ich bin gerade etwas verwirrt, weil in deinem Text die Worte Daten und Variablen wild ihre Bedeutung wechseln.<br />
Also du bekommst vom Lesegerät beispielsweise dies:</p>
<pre><code>0414B7E73A
0414B7E73A
1214C7E74F
0414B7E73A
1214C7E74F
</code></pre>
<p>Korrekt?</p>
<p>Und jetzt willst du beispielsweise automatisch jedes Vorkommen von 0414B7E73A durch a ersetzen und jedes Vorkommen von 1214C7E74F durch b, so dass aus den obigen Beispieldaten dies würde:</p>
<pre><code>a
a
b
a
b
</code></pre>
<p>Korrekt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1879152</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1879152</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Thu, 08 Apr 2010 07:48:29 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe bei Variablen on Thu, 08 Apr 2010 07:49:28 GMT]]></title><description><![CDATA[<p>das ist soweit korrekt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1879154</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1879154</guid><dc:creator><![CDATA[mechatroniker]]></dc:creator><pubDate>Thu, 08 Apr 2010 07:49:28 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe bei Variablen on Thu, 08 Apr 2010 08:02:32 GMT]]></title><description><![CDATA[<p>mechatroniker schrieb:</p>
<blockquote>
<p>das ist soweit korrekt</p>
</blockquote>
<p>Und wo hast du dann jetzt noch Schwierigkeiten, wenn du die map hast und die Daten hast? Einfach eine Zeile lesen, gelesene Daten als Mapindex benutzen und dann den Buchstaben an diesem Mapindex ausgeben. Wiederholen bis Datenende. Fertig.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1879158</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1879158</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Thu, 08 Apr 2010 08:02:32 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe bei Variablen on Thu, 08 Apr 2010 08:10:40 GMT]]></title><description><![CDATA[<p>&quot; Einfach eine Zeile lesen, gelesene Daten als Mapindex benutzen und dann den Buchstaben an diesem Mapindex ausgeben.&quot;</p>
<p>kannst du das vielleicht etwas genauer erklären?</p>
<p>tia</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1879160</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1879160</guid><dc:creator><![CDATA[mechatroniker]]></dc:creator><pubDate>Thu, 08 Apr 2010 08:10:40 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe bei Variablen on Thu, 08 Apr 2010 09:03:15 GMT]]></title><description><![CDATA[<p>mechatroniker schrieb:</p>
<blockquote>
<p>&quot; Einfach eine Zeile lesen, gelesene Daten als Mapindex benutzen und dann den Buchstaben an diesem Mapindex ausgeben.&quot;</p>
<p>kannst du das vielleicht etwas genauer erklären?</p>
<p>tia</p>
</blockquote>
<p><a href="http://www.cplusplus.com/reference/string/getline/" rel="nofollow">Einfach eine Zeile lesen</a><br />
<a href="http://www.cplusplus.com/reference/stl/map/operator%5B%5D/" rel="nofollow">gelesene Daten als Mapindex benutzen</a><br />
<a href="http://www.cplusplus.com/reference/iostream/ostream/operator%3C%3C/" rel="nofollow">den Buchstaben an diesem Mapindex ausgeben</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1879187</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1879187</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Thu, 08 Apr 2010 09:03:15 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe bei Variablen on Thu, 08 Apr 2010 11:03:18 GMT]]></title><description><![CDATA[<p>vielen Dank für die links SeppJ.</p>
<p>Habe versucht mich dort durchzuarbeiten, jedoch steig ich immer noch nicht dahinter.<br />
Zeile auslesen ist ja alles kein Problem aber der Rest...naja...</p>
<p>Kannst du mir nicht ein Code-Beispiel geben? Falls nicht zu aufwendig?</p>
<p>TIA</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1879261</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1879261</guid><dc:creator><![CDATA[mechatroniker]]></dc:creator><pubDate>Thu, 08 Apr 2010 11:03:18 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe bei Variablen on Thu, 08 Apr 2010 11:10:17 GMT]]></title><description><![CDATA[<p>Sag doch, was du konkret nicht verstehst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1879269</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1879269</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Thu, 08 Apr 2010 11:10:17 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe bei Variablen on Thu, 08 Apr 2010 11:48:38 GMT]]></title><description><![CDATA[<p>&quot;gelesene Daten als Mapindex benutzen und dann den Buchstaben an diesem Mapindex ausgeben.&quot;</p>
<p>die links gibt für mich keinen Aufschluss, wie den nun Daten aus einer .txt als Mapindex benutzt werden</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1879293</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1879293</guid><dc:creator><![CDATA[mechatroniker]]></dc:creator><pubDate>Thu, 08 Apr 2010 11:48:38 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe bei Variablen on Thu, 08 Apr 2010 12:28:34 GMT]]></title><description><![CDATA[<p>Du hast ja geschrieben Zeile lesen kein Problem:</p>
<pre><code class="language-cpp">string geleseneZeile; // ... angenommen der string ist schon von dir gefüllt
map&lt;string, string&gt; meineMap;
// Initialisierung mit den Werten ASDGH123 = a usw..

string dasWasIchWill = meineMap[geleseneZeile];

cout &lt;&lt; dasWasIchWill &lt;&lt; endl;
</code></pre>
<p>#edit: Mit dem map Index könnten dir noch newlines Probleme bereiten.<br />
Kommt drauf an wie genau du die Zeile ausliest. Poste doch mal was du bisher hast wenn hiermit deine Fragen noch nicht beantwortet sind.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1879327</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1879327</guid><dc:creator><![CDATA[blub* 0]]></dc:creator><pubDate>Thu, 08 Apr 2010 12:28:34 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe bei Variablen on Thu, 08 Apr 2010 15:05:24 GMT]]></title><description><![CDATA[<p>bin jetzt erstmal soweit gekommen:</p>
<p>#include &lt;iostream&gt;<br />
#include &lt;fstream&gt;<br />
#include &lt;string&gt;<br />
#include &lt;map&gt;</p>
<p>using namespace std;</p>
<p>int main () {<br />
string line;<br />
ifstream file (&quot;Test.txt&quot;);<br />
if (file.is_open())</p>
<p>{<br />
while (! file.eof() )<br />
{<br />
getline (file,line);</p>
<p>string line;</p>
<p>map &lt;string, string&gt; liste;<br />
liste [&quot;1:042042B230&quot;]= &quot;a&quot; ;<br />
liste [&quot;1:0108827DF6&quot;]= &quot;b&quot; ;<br />
liste [&quot;1:0108827DA0&quot;]= &quot;c&quot; ;<br />
liste [&quot;1:0108827DA9&quot;]= &quot;d&quot; ;</p>
<p>string result = liste [line];<br />
cout &lt;&lt; result &lt;&lt; endl;</p>
<p>}<br />
file.close();<br />
}</p>
<p>else cout &lt;&lt; &quot;Unable to open file&quot;;</p>
<p>cin.get();</p>
<p>}</p>
<p>Wenn ich dies durchlaufen lasse, dann bekomme ich nur Zeichenumbrüche, entsprechend der Anzahl der Zeilenanzahl aus der .txt</p>
<p>Wo ist der Fehler?<br />
Aso und danke erstmal für eure bisherige Hilfe. TOP!!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1879459</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1879459</guid><dc:creator><![CDATA[mechatroniker]]></dc:creator><pubDate>Thu, 08 Apr 2010 15:05:24 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe bei Variablen on Thu, 08 Apr 2010 15:25:26 GMT]]></title><description><![CDATA[<p>Nimm bitte C/C++ Tags..</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;
#include &lt;map&gt;

using namespace std;

int main () {
string line;
ifstream file (&quot;Test.txt&quot;);
if (file.is_open())

{
while (! file.eof() )
{
getline (file,line);

string line;

map &lt;string, string&gt; liste;
liste [&quot;1:042042B230&quot;]= &quot;a&quot; ;
liste [&quot;1:0108827DF6&quot;]= &quot;b&quot; ;
liste [&quot;1:0108827DA0&quot;]= &quot;c&quot; ;
liste [&quot;1:0108827DA9&quot;]= &quot;d&quot; ;

string result = liste [line];
cout &lt;&lt; result &lt;&lt; endl;

}
file.close();
}

else cout &lt;&lt; &quot;Unable to open file&quot;;

cin.get();
}
</code></pre>
<p>Einrücken wäre auch eine gute Sache.</p>
<p>Du erhältst nur Zeilenumbrüche weil in der map kein Element entsprechend dem gefütterten Index vorhanden ist und entsprechend nichts ausgegeben wird, der Zeilenumbruch entsteht durch das endl.</p>
<p>Wie gesagt, das Problem sind die newlines die noch zusätzlich in der Datei sind.</p>
<p>Entweder du entfernst sie nach dem einlesen der Zeile oder du schreibst die eben auch noch mit in den Index.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1879480</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1879480</guid><dc:creator><![CDATA[blub* 0]]></dc:creator><pubDate>Thu, 08 Apr 2010 15:25:26 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe bei Variablen on Thu, 08 Apr 2010 15:59:09 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;
#include &lt;map&gt;

using namespace std;

int
main ()
{
  string line;                  // guck mal hier
  ifstream file (&quot;Test.txt&quot;);
  if (file.is_open ())

    {
      while (!file.eof ())
	{
	  getline (file, line);

	  string line;     // Und hier

	  map &lt; string, string &gt; liste;
	  liste[&quot;1:042042B230&quot;] = &quot;a&quot;;
	  liste[&quot;1:0108827DF6&quot;] = &quot;b&quot;;
	  liste[&quot;1:0108827DA0&quot;] = &quot;c&quot;;
	  liste[&quot;1:0108827DA9&quot;] = &quot;d&quot;;

	  string result = liste[line];
	  cout &lt;&lt; result &lt;&lt; endl;

	}
      file.close ();
    }

  else
    cout &lt;&lt; &quot;Unable to open file&quot;;

  cin.get ();
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1879502</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1879502</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Thu, 08 Apr 2010 15:59:09 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe bei Variablen on Fri, 09 Apr 2010 06:24:02 GMT]]></title><description><![CDATA[<p>DANKE SCHÖÖÖN!</p>
<p>entfernen vom zweiten &quot;string line&quot; und es funktioniert!</p>
<p>LG<br />
Mechtroniker</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1879818</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1879818</guid><dc:creator><![CDATA[mechatroniker]]></dc:creator><pubDate>Fri, 09 Apr 2010 06:24:02 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe bei Variablen on Fri, 09 Apr 2010 08:17:15 GMT]]></title><description><![CDATA[<p>mechatroniker schrieb:</p>
<blockquote>
<p>DANKE SCHÖÖÖN!</p>
<p>entfernen vom zweiten &quot;string line&quot; und es funktioniert!</p>
<p>LG<br />
Mechtroniker</p>
</blockquote>
<p>Weißt du denn auch, warum man es trotz der zwei <code>string line</code> compilieren konnte, es danach aber nicht mehr funktioniert hat? Du kannst hier etwas wichtiges über C++ lernen, wenn du dies verstehst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1879858</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1879858</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Fri, 09 Apr 2010 08:17:15 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe bei Variablen on Fri, 09 Apr 2010 09:52:17 GMT]]></title><description><![CDATA[<p>nein das weiß ich nicht...</p>
<p>wenn´s kurz geht kannst du mir das noch verraten...ansonsten find ich es aber auch nicht so wild...<br />
ihr habt mir bisher schon weiter geholfen als ich erwartet hätte</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1879899</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1879899</guid><dc:creator><![CDATA[mechatroniker]]></dc:creator><pubDate>Fri, 09 Apr 2010 09:52:17 GMT</pubDate></item><item><title><![CDATA[Reply to Hilfe bei Variablen on Fri, 09 Apr 2010 10:02:30 GMT]]></title><description><![CDATA[<p>mechatroniker schrieb:</p>
<blockquote>
<p>nein das weiß ich nicht...</p>
<p>wenn´s kurz geht kannst du mir das noch verraten...ansonsten find ich es aber auch nicht so wild...<br />
ihr habt mir bisher schon weiter geholfen als ich erwartet hätte</p>
</blockquote>
<p>Das kann ich leider nicht kurz erklären, sonst hätte ich es getan. Ich kann dich da nur an Literatur verweisen. Schau mal in einem Lehrbuch nach Scope (zu deutsch Gültigkeitsbereich), Lebensdauer von Variablen und den Regeln zur Namensauflösung. Das dürfte alles zusammen in einem der Kapitel des Lehrbuchs stehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1879909</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1879909</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Fri, 09 Apr 2010 10:02:30 GMT</pubDate></item></channel></rss>