Re:Are pointers and arrays equivalent in C? (2009)
by pikachu_is_cool on Saturday March 21, 2015 @02:56PM
(#9243797)
C doesn't have pass by reference.
[ Parent
| on HN ]
Re:Are pointers and arrays equivalent in C? (2009)
by ArkyBeagle on Saturday March 21, 2015 @03:41PM
(#9243949)
It has "pass a pointer by value", which works out conceptually to the same thing, only with slightly different syntax.
Re:Are pointers and arrays equivalent in C? (2009)
by pikachu_is_cool on Monday March 23, 2015 @08:59PM
(#9254317)
Yeah I was talking about this:
> was using & to show pass-by-reference
Re:Are pointers and arrays equivalent in C? (2009)
by krylon on Saturday March 21, 2015 @03:28PM
(#9243897)
No, it does not. That is why pointers are so important in C. But to a newbie, the difference between a local variable and a pointer to it can be rather confusing, and the fact that with arrays this difference becomes rather blurry unless one has a good mental model of what the compiler turns your code into, makes it even more confusing.
Given that some data structure such as linked lists are highly inconvenient or even impossible to implement without dynamic memory management, one is pretty much bound to writing code that is either primitive (not always a bad thing) or horrible to look at (and maintain) until one understands pointers.