where many noticed that the size of the character buffer is defined as:
const int bufferSize = 255; char buffer[bufferSize+1]; why add one? After all, char can store 256 values, why not immediately define it like this:
const int bufferSize = 256; char buffer[bufferSize]; same for character array:
const int MAX = 256; char array[MAX];