In my class we are writing our own copy of C\'s malloc() function. To test my code (which can currently allocate space fine) I was using:
char* ptr = my_mal
It stops printing when it reaches a null character (\0), because %s expects the string to be null terminated (i.e., it expects the argument to be a C string).
The string literal "test\nd" is null terminated (all string literals are null terminated). Your character array ptr is not, however, because you only copy six characters into the buffer (Hello\n), and you do not copy the seventh character--the null terminator.