No, it doesn't. It has pointers, but they're not quite the same thing.
In particular, all arguments in C are passed by value, rather than pass-by-reference being available as in C++. Of course, you can sort of simulate pass-by-reference via pointers:
void foo(int *x)
{
*x = 10;
}
...
int y = 0;
foo(&y); // Pass the pointer by value
// The value of y is now 10
For more details about the differences between pointers and references, see this SO question. (And please don't ask me, as I'm not a C or C++ programmer :)
Answer from Jon Skeet on Stack OverflowDoes C have references? - Stack Overflow
Which C reference book do you recommend?
pointers vs references
Are you using C++? C++ has both pointers * and references &. References are really just syntactic sugar (a convenience) for pointers.
C has no references, though.
More on reddit.comC: A Reference Manual 6th edition?
Videos
Could the language have just used pointers instead ? I don’t really understand purpose of reference except code might be easier to write.
No, it doesn't. It has pointers, but they're not quite the same thing.
In particular, all arguments in C are passed by value, rather than pass-by-reference being available as in C++. Of course, you can sort of simulate pass-by-reference via pointers:
void foo(int *x)
{
*x = 10;
}
...
int y = 0;
foo(&y); // Pass the pointer by value
// The value of y is now 10
For more details about the differences between pointers and references, see this SO question. (And please don't ask me, as I'm not a C or C++ programmer :)
Conceptually, C has references, since pointers reference other objects.
Syntactically, C does not have references as C++ does.