Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think a better way to think about is to say that when you type:

int a[10];

you allocate 10 integers and "a" is the pointer to the first one of them.

Arrays are just memory, just like what you get wen calling malloc, and memory is accessed using pointers in C.



That mindset doesn't cover sizeof(a) properly.


I agree, that's an inconsistency I would rather fix, then the one OP suggests.


Minor nitpick: there is no allocation going on here - you’re simply reserving a fixed-size buffer on the stack (assuming the array is local to a function).


I would call that a stack allocation, but yes they are slightly different. In my mind its a feature that arrays allocated on the stack and heap can interchangeably be given as an argument to a function.


To allocate means to get or reserve something (for lack of an even better word, as a non-native). This is a perfectly valid use of allocation.

What you mean is maybe more aptly named "dynamic (memory) allocation".




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: