<?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[variablen im Speicher, Adresse auslesen]]></title><description><![CDATA[<p>Hallo zusammen,<br />
habe mich soeben im Forum angemeldet, nachdem ich hier schon viel gelesen habe.<br />
programmiere derzeit in Python und PHP und versuche mich nun auch in c++.<br />
Nun bin ich aber an einer Stelle angekommen, wo mir auch google usw. nicht mehr weiterhilft.<br />
Vielleicht könnt ihr mir folgendes erklären:<br />
Warum erhalte ich die Adresse der char Variablen nicht als Ausgabe?</p>
<pre><code>#include &lt;cstdio&gt;
#include &lt;cstdlib&gt;
#include &lt;iostream&gt;
#include &quot;string.h&quot;
using namespace std;

int main ()
{
    bool b;
    char c;
    string sz;
    int  n;
    long l;
    float f;
    double d;

    cout &lt;&lt;&quot;bool: &quot; &lt;&lt; sizeof b &lt;&lt;endl;
    cout &lt;&lt;&quot;char: &quot; &lt;&lt; sizeof c &lt;&lt;endl;
    cout &lt;&lt;&quot;string: &quot;&lt;&lt; sizeof sz &lt;&lt;endl;
    cout &lt;&lt;&quot;int: &quot; &lt;&lt; sizeof n &lt;&lt;endl;
    cout &lt;&lt;&quot;long: &quot; &lt;&lt; sizeof l &lt;&lt;endl;
    cout &lt;&lt;&quot;float: &quot; &lt;&lt; sizeof f &lt;&lt;endl;
    cout &lt;&lt;&quot;double: &quot; &lt;&lt; sizeof d &lt;&lt;endl;

    cout &lt;&lt;&quot;bool: &quot; &lt;&lt; &amp;b &lt;&lt;endl;
    cout &lt;&lt;&quot;char: &quot; &lt;&lt; &amp;c &lt;&lt;endl;
    cout &lt;&lt;&quot;string: &quot;&lt;&lt; &amp;sz&lt;&lt;endl;
    cout &lt;&lt;&quot;int: &quot; &lt;&lt; &amp;n &lt;&lt;endl;
    cout &lt;&lt;&quot;long: &quot; &lt;&lt; &amp;l &lt;&lt;endl;
    cout &lt;&lt;&quot;float: &quot; &lt;&lt; &amp;f &lt;&lt;endl;
    cout &lt;&lt;&quot;double: &quot; &lt;&lt; &amp;d &lt;&lt;endl;

    return 0;
}
</code></pre>
<p>Ausgabe:</p>
<pre><code class="language-cpp">[code]
bool: 1
char: 1
string: 8
int: 4
long: 8
float: 4
double: 8
bool: 0x7fffcef88d6f
char:                     &lt;-----enthält keinen Wert
string: 0x7fffcef88d50
int: 0x7fffcef88d68
long: 0x7fffcef88d48
float: 0x7fffcef88d64
double: 0x7fffcef88d40
[/code]
</code></pre>
<p>Für Antworten schon mal Danke im Voraus<br />
catdog<br />
P.S. Bin das erste mal in einem Forum.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/231546/variablen-im-speicher-adresse-auslesen</link><generator>RSS for Node</generator><lastBuildDate>Fri, 25 Sep 2026 20:53:31 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/231546.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 12 Jan 2009 13:28:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to variablen im Speicher, Adresse auslesen on Mon, 12 Jan 2009 13:28:09 GMT]]></title><description><![CDATA[<p>Hallo zusammen,<br />
habe mich soeben im Forum angemeldet, nachdem ich hier schon viel gelesen habe.<br />
programmiere derzeit in Python und PHP und versuche mich nun auch in c++.<br />
Nun bin ich aber an einer Stelle angekommen, wo mir auch google usw. nicht mehr weiterhilft.<br />
Vielleicht könnt ihr mir folgendes erklären:<br />
Warum erhalte ich die Adresse der char Variablen nicht als Ausgabe?</p>
<pre><code>#include &lt;cstdio&gt;
#include &lt;cstdlib&gt;
#include &lt;iostream&gt;
#include &quot;string.h&quot;
using namespace std;

int main ()
{
    bool b;
    char c;
    string sz;
    int  n;
    long l;
    float f;
    double d;

    cout &lt;&lt;&quot;bool: &quot; &lt;&lt; sizeof b &lt;&lt;endl;
    cout &lt;&lt;&quot;char: &quot; &lt;&lt; sizeof c &lt;&lt;endl;
    cout &lt;&lt;&quot;string: &quot;&lt;&lt; sizeof sz &lt;&lt;endl;
    cout &lt;&lt;&quot;int: &quot; &lt;&lt; sizeof n &lt;&lt;endl;
    cout &lt;&lt;&quot;long: &quot; &lt;&lt; sizeof l &lt;&lt;endl;
    cout &lt;&lt;&quot;float: &quot; &lt;&lt; sizeof f &lt;&lt;endl;
    cout &lt;&lt;&quot;double: &quot; &lt;&lt; sizeof d &lt;&lt;endl;

    cout &lt;&lt;&quot;bool: &quot; &lt;&lt; &amp;b &lt;&lt;endl;
    cout &lt;&lt;&quot;char: &quot; &lt;&lt; &amp;c &lt;&lt;endl;
    cout &lt;&lt;&quot;string: &quot;&lt;&lt; &amp;sz&lt;&lt;endl;
    cout &lt;&lt;&quot;int: &quot; &lt;&lt; &amp;n &lt;&lt;endl;
    cout &lt;&lt;&quot;long: &quot; &lt;&lt; &amp;l &lt;&lt;endl;
    cout &lt;&lt;&quot;float: &quot; &lt;&lt; &amp;f &lt;&lt;endl;
    cout &lt;&lt;&quot;double: &quot; &lt;&lt; &amp;d &lt;&lt;endl;

    return 0;
}
</code></pre>
<p>Ausgabe:</p>
<pre><code class="language-cpp">[code]
bool: 1
char: 1
string: 8
int: 4
long: 8
float: 4
double: 8
bool: 0x7fffcef88d6f
char:                     &lt;-----enthält keinen Wert
string: 0x7fffcef88d50
int: 0x7fffcef88d68
long: 0x7fffcef88d48
float: 0x7fffcef88d64
double: 0x7fffcef88d40
[/code]
</code></pre>
<p>Für Antworten schon mal Danke im Voraus<br />
catdog<br />
P.S. Bin das erste mal in einem Forum.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1643880</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1643880</guid><dc:creator><![CDATA[catdog]]></dc:creator><pubDate>Mon, 12 Jan 2009 13:28:09 GMT</pubDate></item><item><title><![CDATA[Reply to variablen im Speicher, Adresse auslesen on Mon, 12 Jan 2009 13:35:11 GMT]]></title><description><![CDATA[<p>Konvertier die Adresse nach long (unter 32 Bit) und benutze den hex-Manipulator, dann klappt es.</p>
<pre><code class="language-cpp">cout &lt;&lt; hex &lt;&lt; (long)&amp;c &lt;&lt; endl;
</code></pre>
<p>Er versucht vermutlich, den Zeiger zu dereferenzieren oder so, keine Ahnung... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1643887</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1643887</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Mon, 12 Jan 2009 13:35:11 GMT</pubDate></item><item><title><![CDATA[Reply to variablen im Speicher, Adresse auslesen on Mon, 12 Jan 2009 13:39:59 GMT]]></title><description><![CDATA[<p>catdog schrieb:</p>
<blockquote>
<p>Vielleicht könnt ihr mir folgendes erklären:<br />
Warum erhalte ich die Adresse der char Variablen nicht als Ausgabe?</p>
</blockquote>
<p>Ehrlich gesagt: Keine Ahnung.<br />
Aber andere Anmerkungen:</p>
<p>1. Verwende für C/C++ bitte statt den code-Tags die cpp-Tags (Wegen farblicher Syntaxhervorhebung), und für allgemein fixe Anzeige (z.B. Ausgaben) wiederum die code-Tags.<br />
2. Ist &quot;string.h&quot; eine eigene Datei? Weil std::string aus der Standardbibliothek &lt;string&gt; heißt.<br />
3. Wozu bindest du die C-Bibliotheken &lt;cstdio&gt;, &lt;cstdlib&gt; ein? Verwenden tust du diese nicht.<br />
4. Ich muss sagen das &quot;sizeof b&quot; mich als Schreibweise überrascht, üblich ist eigentlich sizeof(b).<br />
5. Dies ist nur als Vorgriff zu sehen: Bitte gewöhn dir die &quot;using namespace&quot;-Schreibweise nicht bei Headern an (Macht Namensräume global bekannt, was das Prinzip der Namensräume unterwandert).</p>
<p>cu André</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1643894</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1643894</guid><dc:creator><![CDATA[asc]]></dc:creator><pubDate>Mon, 12 Jan 2009 13:39:59 GMT</pubDate></item><item><title><![CDATA[Reply to variablen im Speicher, Adresse auslesen on Mon, 12 Jan 2009 13:45:26 GMT]]></title><description><![CDATA[<p>Der Compiler nimmt die Version von operator&lt;&lt; die einen <em>const char</em>* erwartet. Drum wird versucht ein String in den Stream zu schreiben und die Adresse wird nicht gecastet.</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/14941">@asc</a>: Die Klammern die man üblicherweise bei sizeof macht, gehören ja nicht zum Operator. Man siehts so aber tatsächlich recht selten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1643896</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1643896</guid><dc:creator><![CDATA[David_pb]]></dc:creator><pubDate>Mon, 12 Jan 2009 13:45:26 GMT</pubDate></item><item><title><![CDATA[Reply to variablen im Speicher, Adresse auslesen on Mon, 12 Jan 2009 13:50:21 GMT]]></title><description><![CDATA[<p>Erstmal vielen Dank für die schnellen Antworten.<br />
Funktioniert ja prima hier.<br />
<a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/16702">@_matze</a><br />
nach Konvertierung zu hex funktioniert alles.</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/14941">@asc</a><br />
Danke für deine Tips bzgl. Formatierung.<br />
Die include Dateien sind eigentlich nicht für diese Zeilen gewesen.<br />
Habe sie aber aus Bequemlichkeit stehen lassen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /></p>
<p>-- sizeof b -- sizeof(b)<br />
Erste Variante steht in meinem c++ für Dummies Buch<br />
Mir kam die Schreibweise auch schon ungewöhnlich vor.</p>
<p>Bzgl. namespace.....werde deinen Rat befolgen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1643911</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1643911</guid><dc:creator><![CDATA[catdog]]></dc:creator><pubDate>Mon, 12 Jan 2009 13:50:21 GMT</pubDate></item></channel></rss>