I am struggling to understand the usefulness of pointers. I've read answers to similar questions but they don't seem to make things clear for me.
Lets say we want to allocate some space dynamically for the use of a variable, we would do something like this: int *i = malloc(sizeof(int))
. I do not understand why the creator(s) of C felt the need to have a pointer that does the job. Why wouldn't they have malloc return (void) type of memory (correct me if that's not possible in general) instead of a (void*) pointer to that memory. The syntax for that would be something like int i = malloc(sizeof(int))
.
I understand that the question may be abstract because I don't have all the knowledge that is needed to explain what I have in my brain. If something that I say doesn't make sense feel free to tell me so that I can elaborate. Thank you in advance!