Quote:
still it is reading some redundant data
It is not reading 'redundant data'. Simply your buffer contains uninitialised data (or previously initialised data) after the
bytes_read
limit: after each read operation only data from
buffer[0]
to
buffer[bytes_read-1]
is valid.