Why allocating a 0 size char block works in this case? But if I write char *string = NULL; it won\'t work.
I\'m using Visual Studio.
malloc definition:
Allocates a block of size bytes of memory, returning a pointer to the beginning of the block.
The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.
If size is zero, the return value depends on the particular library implementation (it may or may not be a null pointer), but the returned pointer shall not be dereferenced.
Taken from here and found this related question.