The reason you see memory corruption is that you can't rely that data you read is a "C-style string", i.e. a null-terminated char* string. So strlen(buffer) might discover a too-long string because it just goes until it finds a null char. The solution is to only write the number of bytes which are read - this number is given to you by read.
Hi Austin,
The reason you see memory corruption is that you can't rely that data you read is a "C-style string", i.e. a null-terminated
char*
string. Sostrlen(buffer)
might discover a too-long string because it just goes until it finds a null char. The solution is to only write the number of bytes which are read - this number is given to you byread
.Evan