why are you limiting your char length?.. right now you are hitting a null pointer while reading your memcopied string before your max size limit is reached. this is causing your heap to corrupt and a crash… if you need pre-defined strings, why not use a enum? if not, then you did not think of situations that your input might be utf8 or even utf16…