get size of dynamic pointer C++
<p>I want to write a dynamic pointer to a file in C++.</p>

<p>This is my declaration in header file:</p>

<pre><code>byte* buffer;
</code></pre>

<p>Then in Cpp file, I allocated it:</p>

<pre><code>buffer = new byte[1000];
</code></pre>

<p>However the size will be bigger than 1000 in dynamic allocation.</p>

<p>Then I write to the file:</p>

<p>ofstream myfile;</p>

<pre><code>myfile.open("test.txt", ios::binary);
myfile.write((char*)buffer, 1000);  
myfile.close();
</code></pre>

<p>If I specify the length of buffer to 1000, then the rest of bytes after 1000 will be discarded. If I use: sizeof(buffer) then it is only 1 byte written.</p>

<p>How can I get the dynamic size of the buffer?</p>

<p>Thanks in advance.</p>
