question about string to file
<p>here is code    </p>

<pre><code>#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;cstring&gt;
using namespace std;

int main()
{
  ofstream out("test", ios::out | ios::binary);

  if(!out) {
    cout &lt;&lt; "Cannot open output file.\n";
    return 1;
  }

  double num = 100.45;
  char str[] = "www.java2s.com";

  out.write((char *) &amp;num, sizeof(double));
  out.write(str, strlen(str));

  out.close();

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

<p>i dont understand only this</p>

<pre><code>out.write((char *) &amp;num, sizeof(double));
</code></pre>

<p>why we need  <code>(char *)&amp;num?</code>or <code>sizeof(double)?</code></p>
