In your first code n_ptr is pointing to name so *n_ptr = 7; will assign the value 7 to name.
In your second code you have not told what n_ptr should point to so where are you trying to write the value 7? You can't be sure where n_ptr points to, but most probable is that it points to some memory location where your program is not allowed to write so that is why it crashes.