char ch = 'c';
this is a C command, that (internally) reserves 1 Byte to store/hold the character "c" in it, on an (for the user) unknown memory position (if the application is running, then on a place into the memory, that the application reserves before it is execute).
char *char_ptr = &ch;
This is a command, that:
declare a "array" of characters (char's), indicate as pointer with the asterisk,
1a. the size of this "pointer" variable has the size of the users CPU bandwide (a user under 32-Bit OS, has 4 Bytes in length, a user under a 64-Bit OS has 8 Bytes in size. This is the default size.
with the ampsign &, you reference to a memory position - it will point to "ch", the command, you have given by char ch = 'c';
note: this is a reference, no pointer !
As such, the memory value "c" will not change.
As such, you can get undefined breakable/behavoiur, because you "reserved" with ch only one Byte, and the application is willing to remember this on a good OS, the application crash.
This has the background, that you reference "to the memory" position, and this part of memory will be protected by the application OS.
If you have luck, the size of _ptr is the same as your computer cpu arch.
If you have luck, the operation system will copy the one byte of ch to the position to the address of _ptr.
*(char_ptr+1) = 'h';
with this command, you "get" the address of _ptr, and right 1 byte left (counting from 0), and assign the character 'h' to this position, and override the content of the 4 Byte sized _ptr (32-Bit cpu).
This make the result "cxxx" to "chxx" - xxx stands for random bytes.
*(char_ptr+2) = '\0';
the same here:
you "get" the address of _ptr, and jump 2 byte to right (counting from 0), and assign the character 'h', to this position, and override the content of the 4 Byte sized _ptr (32-bit cpu).
This make the result "chxx" to "ch\0x".
This means, you formed a literal/string, that is indicate with a null terminated character, that is used to mark the string as to be ended there on this position.
printf("char_ptr as string = %s\n", char_ptr);
this print the _ptr (string) value from the char_ptr at its memory address on screen.
Because you have the literal "ch\0x";
You will get see the string "ch"
the command sequence \n is provided, and has a "newline" starting as result.
char *char_ptr = 'c';
is a constraint violation. It is illegal to use non-zero integer constant to initialize a pointer. – AnT