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

Arrays and pointers are completely different entities in C. The only reason people think there's any sort of equivalence is because:

1. The "array indexing operator" [] actually works only on pointers.

2. Arrays are automatically converted to a pointer to the first array element whenever necessary.

3. Arrays are really uncommon in C, and many things we think of as arrays are not arrays as C considers them. Declare a function parameter with []? That's a pointer, not an array. Malloc a bunch of memory? Not an array.



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

Search: