<?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[datein binär einlesen]]></title><description><![CDATA[<p>Hallo zusammen,<br />
ich habe ifstream read aus einem Datei glesen und den Wert in einem char test[4] gespeichert. Jetzt steht in test[3]= 68 &quot;D&quot;. ICh würde gerne die 68 weiterverarbeiten aber wenn ich atoi (test) nehme kriege ich &quot;D&quot; und nicht die 68. Kann mir jemand helfe?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/252491/datein-binär-einlesen</link><generator>RSS for Node</generator><lastBuildDate>Mon, 14 Sep 2026 11:27:37 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/252491.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 20 Oct 2009 17:09:46 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to datein binär einlesen on Tue, 20 Oct 2009 17:09:46 GMT]]></title><description><![CDATA[<p>Hallo zusammen,<br />
ich habe ifstream read aus einem Datei glesen und den Wert in einem char test[4] gespeichert. Jetzt steht in test[3]= 68 &quot;D&quot;. ICh würde gerne die 68 weiterverarbeiten aber wenn ich atoi (test) nehme kriege ich &quot;D&quot; und nicht die 68. Kann mir jemand helfe?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1795406</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1795406</guid><dc:creator><![CDATA[borhan]]></dc:creator><pubDate>Tue, 20 Oct 2009 17:09:46 GMT</pubDate></item><item><title><![CDATA[Reply to datein binär einlesen on Tue, 20 Oct 2009 17:18:22 GMT]]></title><description><![CDATA[<p>Ganz einfach: Ob da 68 oder D ausgegeben wird ist eine reine Sache wie die Ausgabe formatiert steht. Im Speicher steht da nur der Wert 68. Fazit: Du kannst einfach drauflos rechnen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1795411</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1795411</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 20 Oct 2009 17:18:22 GMT</pubDate></item><item><title><![CDATA[Reply to datein binär einlesen on Tue, 20 Oct 2009 18:14:11 GMT]]></title><description><![CDATA[<p>danke für deinen schnellen antwort. Ich möchte die zahl mit 3 ANDen und deswegen speichere ich zuerst</p>
<p>int test;</p>
<p>dann {in char wert ist mein '68'}</p>
<p>test= atoi (wert);<br />
ich bekomme aber für test immer null</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1795443</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1795443</guid><dc:creator><![CDATA[borhan]]></dc:creator><pubDate>Tue, 20 Oct 2009 18:14:11 GMT</pubDate></item><item><title><![CDATA[Reply to datein binär einlesen on Tue, 20 Oct 2009 18:19:23 GMT]]></title><description><![CDATA[<p>Was für ein Test?! - Post mal den Code, den du hast.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1795447</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1795447</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Tue, 20 Oct 2009 18:19:23 GMT</pubDate></item><item><title><![CDATA[Reply to datein binär einlesen on Tue, 20 Oct 2009 18:26:18 GMT]]></title><description><![CDATA[<p>code:<br />
char byte5 [1];<br />
char byte5Bis7 [3];<br />
ifstream file;<br />
file.open(&quot;test.vob&quot;,ios::binary);<br />
file.read (byte5,1);</p>
<p>so jetzt habe ich in byte[0]= 68 &quot;D&quot; stehen. Ich möchte die 68 mit<br />
3 anden also:<br />
68 &amp; 3;<br />
dafür mache ich<br />
int intWert;<br />
intWert =atoi(byte5);</p>
<p>was mache ich falsch</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1795449</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1795449</guid><dc:creator><![CDATA[borhany]]></dc:creator><pubDate>Tue, 20 Oct 2009 18:26:18 GMT</pubDate></item><item><title><![CDATA[Reply to datein binär einlesen on Tue, 20 Oct 2009 18:44:17 GMT]]></title><description><![CDATA[<p>borhany schrieb:</p>
<blockquote>
<p>code:<br />
char byte5 [1];<br />
char byte5Bis7 [3];<br />
ifstream file;<br />
file.open(&quot;test.vob&quot;,ios::binary);<br />
file.read (byte5,1);</p>
<p>so jetzt habe ich in byte[0]= 68 &quot;D&quot; stehen. Ich möchte die 68 mit<br />
3 anden also:<br />
68 &amp; 3;<br />
dafür mache ich<br />
int intWert;<br />
intWert =atoi(byte5);</p>
<p>was mache ich falsch</p>
</blockquote>
<p>Ein paar Sachen sind falsch:</p>
<ol>
<li>byte5 ist etwas ganz anderes als byte5[0]. Beschäftige dich ein bisschen mit Arrays, um den Unterschied zu lernen.</li>
<li>atoi macht etwas anderes als du annimmst. Schlage das mal in einer Referenz nach.</li>
<li>Wenn du cstrings (das heißt char Arrays + C funktionen wie atoi) verwenden willst, musst du beachten, dass cstrings am Ende noch Platz für ein Nullterminierungszeichen brauchen. Da du aber C++ machen willst, hast du sowas gar nicht nötig, weshalb ich hier nicht näher drauf eingehen will.</li>
<li>Wie schon gesagt, kann man mit char direkt rechnen, wie mit ints auch. Somit ist eine mögliche Lösung:</li>
</ol>
<pre><code class="language-cpp">char foo = 'D';
  cout &lt;&lt; (foo &amp; 3) &lt;&lt; endl;  // gibt 0, da 68 &amp; 3 = 0
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1795457</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1795457</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 20 Oct 2009 18:44:17 GMT</pubDate></item><item><title><![CDATA[Reply to datein binär einlesen on Tue, 20 Oct 2009 20:25:11 GMT]]></title><description><![CDATA[<p>danke für dein ANtwort. Kannst du mir vielleicht sagen wie ich ein<br />
char charWert []= &quot;256&quot; mit einem int intWert = 256 anden kann.<br />
also<br />
char test = charWert &amp; intWert;<br />
Wozu Arrays da sind weiss ich. Ich muss aber ein Wert herauskriegen, der in unterschiedlichen Bytes steckt das ist mein Prblem</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1795510</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1795510</guid><dc:creator><![CDATA[borhany]]></dc:creator><pubDate>Tue, 20 Oct 2009 20:25:11 GMT</pubDate></item><item><title><![CDATA[Reply to datein binär einlesen on Tue, 20 Oct 2009 20:43:17 GMT]]></title><description><![CDATA[<p>borhany schrieb:</p>
<blockquote>
<p>danke für dein ANtwort. Kannst du mir vielleicht sagen wie ich ein<br />
char charWert []= &quot;256&quot; mit einem int intWert = 256 anden kann.<br />
also<br />
char test = charWert &amp; intWert;<br />
Wozu Arrays da sind weiss ich. Ich muss aber ein Wert herauskriegen, der in unterschiedlichen Bytes steckt das ist mein Prblem</p>
</blockquote>
<p>Das ist wiederum der Fall, wofür atoi da ist. Oder besser noch stringstream, wenn du die FAQ gelesen hättest. Beide funktionieren aber nicht mit einfachen char Arrays, sondern mit C strings. D.h. du musst dafür Sorge tragen, dass deine char Arrays nullterminiert sind und auch genügend Platz für das Terminierungszeichen vorhanden ist.</p>
<p>edit: Und das wirft dann wieder die Frage auf, warum du mit char Arrays arbeitest und nicht mit std::string?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1795520</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1795520</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 20 Oct 2009 20:43:17 GMT</pubDate></item></channel></rss>