R
Rakesh Sinha
Hi,
I am writing this application in C++.
It reads data from binary files.
My current requirement is that: Given a positive number N, I have to
read in N bytes from the input stream (which is from a binary file ).
My code fragment looks as follows:
void MyStream ::readStream(char * buffer, size_t length) {
is.get( buffer, length + 1); //read length bytes from the stream
// 'is' -> field of type istream .
}
The invocation fragment looks as follows:
char * buffer = new char[length + 1];
readStream(buffer, length);
The problem occurs when the binary stream contains a null character in
it.
Suppose, if I try to read 10 characters from the stream, and the fourth
character happens to be a null character (i.e 0 ) , then only 3
characters
are read. I am looking for a work-around to read 10 characters i.e read
past this null character here. Is there any workaround to this ?
I am writing this application in C++.
It reads data from binary files.
My current requirement is that: Given a positive number N, I have to
read in N bytes from the input stream (which is from a binary file ).
My code fragment looks as follows:
void MyStream ::readStream(char * buffer, size_t length) {
is.get( buffer, length + 1); //read length bytes from the stream
// 'is' -> field of type istream .
}
The invocation fragment looks as follows:
char * buffer = new char[length + 1];
readStream(buffer, length);
The problem occurs when the binary stream contains a null character in
it.
Suppose, if I try to read 10 characters from the stream, and the fourth
character happens to be a null character (i.e 0 ) , then only 3
characters
are read. I am looking for a work-around to read 10 characters i.e read
past this null character here. Is there any workaround to this ?