You cannot delete
an automatically allocated array. Remove the delete [] chbuffer;
statement.
In general, delete
is only used when paired with new
. You could have allocated chbuffer
like this:
char *chbuffer = new char[fsize + 1];
in which case you would want to use delete [] chbuffer
.