views:

13

answers:

0

Hi,

I'm using fstream to read a stream from a binary file. I use the method get().

fstream f1("Log.dat", ios::in | ios::binary);
char zMsgSize[MSG_SIZE];
zMsgSize[0] = '\0'; 
f1.get(zMsg, CHR_END);

CHR_END is a special terminating character that I have put in the file earlier. There are null characters in the file I'm reading, that's why I'm trying to read it as a stream. My problem is the get() method not reading the stream until the terminating character. When it encounters a null character, the reading terminates. Even when I use another overload of the get() method, in which I can specify the number of characters to be read, the result is the same. What is that I'm doing incorrectly and how can I read this file using a stream completely without a problem with null characters??

Thank You!