I am wondering how does printf() figure out when to stop printing a string, even I haven't put a termination character at the end of the string? I did an experiment by malloc a 10 bytes memory and put exactly 10 characters in it, somehow, the printf could still print out these characters without running out of bound, why?
There's a good chance that one of the characters after the string is NULL, so printf stops there, furthermore, characters that are not NULL after the memory that you malloced might not be printable characters so you won't notice them in the terminal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With