The ouput in txt file thru binary
<pre><code>class Obj{
public:
    int x;
    int y;
    Obj(){
        x = 10;
        y = 12; 
    }

};

int main(){

    Obj obj;
    char *obj_data = (char *) &amp;obj;
    int n = sizeof(obj);

    ofstream out("test.txt");
    out.write(obj_data, n);

    return 0;
}
</code></pre>

<p>When I convert the object pointer to char pointer, did I convert the memory address of the object (in this case the first element which is the address of x) to char?</p>

<p>because the output in the txt file is</p>

<blockquote>
  <p>NOTE!!
  * &lt;-- means weird character</p>
  
  <p>[][][]*[][][][]&lt;-- 1 byte is 1 char, 7 blank space + * is eight
  characters the memory address of the Obj is 002BF770 &lt;-- also eight
  characters</p>
</blockquote>

<p>Did I convert each character in the memory address to char?</p>

<p>But, I notice each time I compile, the memory address changes. So maybe that's wrong. </p>

<p>Also when I change variable <code>y</code> in the class <code>Obj</code> to 10, the text file output also change to </p>

<blockquote>
  <p>[][][][][][][][]&lt;--- eight space notice '' is gone.</p>
</blockquote>

<p>So, my question: what really happens?</p>
