Alf P. Steinbach wrote:
> * Alf P. Steinbach:
> > * nagrik:
> >> Hello group,
> >>
> >> I am reading an 'mpeg file' from the socket. In read socket I specify
> >> a 'char* buffer' to read the file. However, the content of actual data
> >> contain '\0' characters at various places.
> >>
> >> When I read the full content I copy the char* buffer into a string type
> >> variable. The code looks
> >> like
> >>
> >> int len;
> >> char * buf[256];
> >> int size = 256;
> >> string content;
> >>
> >> len = read(sockFd, buf, size);
> >>
> >> content = buf;
> >
> > string content const( buf, buf + len );
>
> Sorry, transposition errors are usually at the letter level, but somehow
> here at the word level.
>
> Should be
>
> string const content( buf, buf + len );
>
Alf,
My content variable is already constructed so after I have buf with me,
the only operation
I am allowed is assignment.
something like
content += buf.
'buf' contains a '\0' character and there will be many more 'buf's I
would like to append to
content. Like
while ( there are more bufs available)
content += buf;
With my implementation, the assignment only copy till the end of '\0'
and later appends
append only after '\0' character and not after the whole buffer, which
I desire. Remember
the '\0' character can occur anywhere in buf and in any buf. I want
content to have full
range of values, including '\0' s.
Too bad C++ does not have a byte type. Any thoughts.
nagrik
> --
> A: Because it messes up the order in which people normally read text.
> Q: Why is it such a bad thing?
> A: Top-posting.
> Q: What is the most annoying thing on usenet and in e-mail?
|