I've taken note of the escape character ('\0'). I'll admit I am familiar with how it works, but it didn't come to mind that it would be the reason why a glitch was output. Thanks.
With that being said, there is a syntax error in the code you gave me:
memblock = new char[size + 1]
This cannot be done, since you can't add an object of type
streampos with an
int. In order to get around this, I had to declared a new
streampos and initialize it to 2:
1 2 3
|
std::streampos size, size2 = 1;
/*Declare memblock and openFile, initialize size to the end of openFile*/
memblock = new char[size + size2];
|
This is the best method I could think of. Do you know of any more efficient alternatives?
Lastly, there was one thing I didn't fully understand:
use the write member function so that you can pass the size as an argument |
std::cout.write(memblock, size);
I'm honestly not sure what we're trying to achieve with this line. Would you care to explain further?
Thanks for replying and for your patience :)