News for hackers. Stuff that matters.
Re:A brief history of one line fixes by EdwardDiego on Saturday March 01, 2014 @10:35PM (#7327580)
Cheers mate, ah, so unless the function declares that it takes a pointer then it's pass-by-val?
Re:A brief history of one line fixes by ggreer on Saturday March 01, 2014 @11:38PM (#7327723)
Everything is pass by value in C, but pointers are values. Functions can't modify the value of a pointer, but they can modify whatever's in the memory pointed to by the pointer. To change the pointer itself, you'd have to pass a pointer to a pointer. Functions like asprintf do this.

C++ added pass by reference (&), which can be a handy bit of syntactic sugar.

Re:A brief history of one line fixes by chetanahuja on Sunday March 02, 2014 @01:35AM (#7328004)
"so unless the function declares that it takes a pointer"

What you're saying is correct in the practical sense. But ggreer's answer is the real technically detailed explanation (everything is passed by value, including pointers to memory. But then you can manipulate that memory you have the pointer to. And that makes it effectively pass-by-reference). Also, C++ adds a language defined pass-by-reference operation... so there's that.