i dont understand the memset thing
char* binary = new char[ElementAmount];
memset(binary, 0, sizeof(binary));
That code is a beginner's error, and tends to yield bugs that are hard to track down. The memset() call should, presumably, be "memset(binary, 0, ElementAmount);" to set all bytes in the dynamically allocated array binary to zero.