I want to write a dynamic pointer to a file in C++.
This is my declaration in header file:
byte* buffer;
Then in Cpp file, I allocated it:
buffer = new byte[1000];
However the size will be bigger than 1000 in dynamic allocation.
Then I write to the file:
ofstream myfile;
myfile.open("test.txt", ios::binary);
myfile.write((char*)buffer, 1000);
myfile.close();
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.
How can I get the dynamic size of the buffer?
Simple: