>>4423680When you call malloc, it calls your operating system under the hood. It tells OS this
>hey, I need some dynamic memory! Gimme some<k here's like 2 KB >2 KB? I need way less! Like 256 bytesand here comes the allocator part. It shrinks this memory to 256 bytes, writes some metadata outside of it, so that it won't have to call OS the next time, and volia. You have 256 bytes.
>>4423686well correct. But C strings are allocated on the static memory, usually. Try doing this:
char* ptr = "string"
*ptr = 'a'
it will give you an error, because ptr points to non-writeable data.