buffer = inBuffer;
touches the pointer, not the content.
So you are discarding what was just allocated (leak).
I guess you want `strcpy()' or `memcpy()' there.
tmpBuff = new char[blockSize];
tmpBuff[blockSize + 1] = '\0'; //out of bounds. the last valid index is blockSize-1
> from X + blockSize +1 so i dont get the last char of the last sub string first in the next one.
make a desk test. Suppose that blockSize=4
You start at X=0 and copy 4 characters, so you copy buffer, buffer, buffer and buffer
In the next iteration you set X=0+4+1=5, missing buffer
As you don't care about '\0' in the source, maybe you want `memcpy()' there.
As you are using c++, take a look at `std::string'