Pass by Value

In the strictest sense of the word, everything in C is pass-by-value. This often confuses beginning C programmers, especially when it comes to pointers, arrays, and structs. So what do we mean when we say pass-by-value and pass-by-reference.

When we pass-by-value we are passing a copy of the variable to a function. When we pass-by-reference we are passing an alias of the variable to a function. C can pass a pointer into a function but that is still pass-by-value. It is copying the value of the pointer, the address, into the function. In C++ a reference is an alias for another variable. C doesn’t have this concept. Read more →