After reading some articles I stayed a few questions:
When I have an uninitialized pointer I can not put into it because there is no memory allocation place! When I have a pointer that points to a variable of type char and I want to put into it with
%s
, the program lets me put up two characters (2 bytes) and beyond that prints me an error. My question is why it is can be put into two letters when char can hold only one byte? Is the program should not fall even two letters?It can't put strings into an array like this: arr = "aaa" Because arr are actually address and not variable that can hold values of char?
I read a little about
undefined behavior
, is it possible to understand that there is a discount that will not use a char pointer to strings and therefore the printing of the string that points to char behaves in an unexpected way?