The default value would be the value assigned by default initialization, which is 0
for an integer type (like char
) and a nullpointer for any pointer type. So, your code would already be wrong here:
printf("\nValue of char ptr:%c\n", *cp);
because the nullpointer can't be dereferenced, it points explicitly nowhere. Dereferencing it leads to undefined behavior.
But, as you define these variables with automatic storage duration (the default in function scope) -- they don't get initialized at all unless you do it yourself. So, their initial value is just indeterminate. This means your first line
printf("\nValue of char c:%c\n", c);
prints some indeterminate value. Whether this is undefined behavior as well depends on whether your char
is by default signed or unsigned. A signed char is allowed to have trap representations, so you could attempt to print something here that isn't a valid representation of a char
-> undefined behavior.
Dereferencing some "random" pointer is undefined behavior as well (and in practice very likely to crash your program).