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 Overflow
🌐
cppreference.com
en.cppreference.com › c
C reference - cppreference.com
Create account · Log in · Page · Discussion · Read · View source · View history · From cppreference.com · C · [edit] Support us · Recent changes · FAQ · Offline version · What links here · Related changes · Upload file · Special pages · Printable version ·
🌐
GNU
gnu.org › software › gnu-c-manual › gnu-c-manual.html
The GNU C Reference Manual
Next: Lexical Elements, Previous: Top, Up: Top [Contents][Index] This is a reference manual for the C programming language as implemented by the GNU Compiler Collection (GCC).
Discussions

Does C really need references?
C does not have references. More on reddit.com
🌐 r/C_Programming
19
0
August 31, 2022
pointers - Passing by reference in C - Stack Overflow
The correct statement is "C does not support implicitly passing a variable by reference" -- you need to explicitly create a reference (with &) before calling the function and explicitly dereference it (with *) in the function. More on stackoverflow.com
🌐 stackoverflow.com
Which C reference book do you recommend?
C: A Reference Manual, Fifth Edition by Harbison and Steele! (c99) https://www.amazon.com/Reference-Manual-Samuel-P-Harbison/dp/013089592X And of course C99 and C89 standards drafts! More on reddit.com
🌐 r/C_Programming
16
6
August 2, 2018
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.com
🌐 r/C_Programming
13
0
October 4, 2018
🌐
Cppreference
cppreference.com
cppreference.com
Create account · Log in · Main Page · Discussion · Read · View source · View history · From cppreference.com · Support us · Recent changes · FAQ · Offline version · What links here · Related changes · Upload file · Special pages · Printable version ·
🌐
Cprogramming.com
cprogramming.com › reference
C and C++ Language Syntax Reference - Cprogramming.com
How to begin Get the book · C tutorial C++ tutorial Game programming Graphics programming Algorithms More tutorials
🌐
Microsoft Learn
learn.microsoft.com › en-us › cpp › c-language › c-language-reference
C Language Reference | Microsoft Learn
August 3, 2021 - The C Language Reference describes the C programming language as implemented in Microsoft C.
🌐
GNU
gnu.org › software › gnu-c-manual
The GNU C Reference Manual - GNU Project - Free Software Foundation
The GNU C Reference Manual is a reference for the C programming language, as implemented by the GNU C Compiler.
Find elsewhere
🌐
W3Schools
w3schools.com › c › c_ref_reference.php
C Reference Documentation
HTML Certificate CSS Certificate JavaScript Certificate Front End Certificate SQL Certificate Python Certificate PHP Certificate jQuery Certificate Java Certificate C++ Certificate C# Certificate XML Certificate ... W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content.
🌐
Code-reference
code-reference.com › c
c Programming | Library | Reference - Code-Reference.com
February 16, 2024 - Online reference for the C (standard) library C is an imperative programming language that the computer scientist Dennis Ritchie developed in the early 1970s at Bell Laboratories for System Programming of the operating system Unix. C Library Overview Library Description assert.h Overview assertion ...
🌐
TutorialsPoint
tutorialspoint.com › cprogramming › c_function_call_by_reference.htm
Function Call by Reference in C
When a function is called by reference, the address of the actual argument variables passed, instead of their values.
🌐
Amazon
amazon.com › C-Pocket-Reference-Peter-Prinz › dp › 0596004362
Amazon.com: C Pocket Reference: 9780596004361: Prinz, Peter, Kirch-Prinz, Ulla: Books
Ideal as an introduction for beginners and a quick reference for advanced programmers, the C Pocket Reference consists of two parts: a compact description of the C language and a thematically structured reference to the standard library.
🌐
QuickRef.ME
quickref.me › home › c cheat sheet & quick reference
C Cheat Sheet & Quick Reference
int myAge = 43; // variable declaration int*ptr = &myAge; // pointer declaration // Reference: output myAge with a pointer // memory address (0x7ffe5367e044) printf("%p\n", ptr); // dereference: output the value of myAge with a pointer (43) printf("%d\n", *ptr); int myNum = 100 + 50; int sum1 = 100 + 50; // 150 (100 + 50) int sum2 = sum1 + 250; // 400 (150 + 250) int sum3 = sum2 + sum2; // 800 (400 + 400) int x = 5; int y = 3; printf("%d", x > y); // returns 1 (true) because 5 is greater than 3 · Comparison operators are used to compare two values
🌐
Codidact
software.codidact.com › posts › 285715
Are there references in C? - Software Development - Codidact
Yes there are references and pass-by-reference in C, though the language has no explicit syntax item called "reference" like C++. In a C context, it is irrelevant that C++ happens to have something called references, which are basically glorified, ...
🌐
Medium
medium.com › @kasra_mp › my-top-4-c-programming-references-f2dda61058
My top 4 C programming references | by Kasra Madadipouya | Medium
December 20, 2022 - I can’t recommend this book enough. You must read it if you are serious about C programming. It is written by Samuel P. Harbison III and Guy L. Steele Jr. As its name says, the book is a reference manual.
🌐
GeeksforGeeks
geeksforgeeks.org › c++ › pass-by-reference-in-c
Pass By Reference In C - GeeksforGeeks
October 19, 2023 - In this method, the address of an argument is passed to the function instead of the argument itself during the function call. Due to this, any changes made in the function will be reflected in the original arguments.
🌐
GeeksforGeeks
geeksforgeeks.org › c++ › references-in-cpp
References in C++ - GeeksforGeeks
Explanation: In this program, ref is a reference to the variable x, meaning ref is just another name for x. When the value of ref is modified, it directly changes the value of x, since both ref and x refer to the same memory location.
Published   1 week ago
🌐
Reddit
reddit.com › r/c_programming › does c really need references?
r/C_Programming on Reddit: Does C really need references?
August 31, 2022 -

Could the language have just used pointers instead ? I don’t really understand purpose of reference except code might be easier to write.

Top answer
1 of 16
367

Because you're passing the value of the pointer to the method and then dereferencing it to get the integer that is pointed to.

2 of 16
206

That is not pass-by-reference, that is pass-by-value as others stated.

The C language is pass-by-value without exception. Passing a pointer as a parameter does not mean pass-by-reference.

The rule is the following:

A function is not able to change the actual parameters value.

(The above citation is actually from the book K&R)


Let's try to see the differences between scalar and pointer parameters of a function.

Scalar variables

This short program shows pass-by-value using a scalar variable. param is called the formal parameter and variable at function invocation is called actual parameter. Note incrementing param in the function does not change variable.

#include <stdio.h>

void function(int param) {
    printf("I've received value %d\n", param);
    param++;
}

int main(void) {
    int variable = 111;

    function(variable);
    printf("variable %d\m", variable);
    return 0;
}

The result is

I've received value 111
variable=111

Illusion of pass-by-reference

We change the piece of code slightly. param is a pointer now.

#include <stdio.h>

void function2(int *param) {
    printf("I've received value %d\n", *param);
    (*param)++;
}

int main(void) {
    int variable = 111;

    function2(&variable);
    printf("variable %d\n", variable);
    return 0;
}

The result is

I've received value 111
variable=112

That makes you believe that the parameter was passed by reference. It was not. It was passed by value, the param value being an address. The int type value was incremented, and that is the side effect that make us think that it was a pass-by-reference function call.

Pointers - passed-by-value

How can we show/prove that fact? Well, maybe we can try the first example of Scalar variables, but instead of scalar we use addresses (pointers). Let's see if that can help.

#include <stdio.h>

void function2(int *param) {
    printf("address param is pointing to %d\n", param);
    param = NULL;
}

int main(void) {
    int variable = 111;
    int *ptr = &variable;

    function2(ptr);
    printf("address ptr is pointing to %d\n", ptr);
    return 0;
}

The result will be that the two addresses are equal (don't worry about the exact value).

Example result:

address param is pointing to -1846583468
address ptr   is pointing to -1846583468

In my opinion this proves clearly that pointers are passed-by-value. Otherwise ptr would be NULL after function invocation.

🌐
Rose-Hulman Institute of Technology
rose-hulman.edu › class › csse › csse132 › 2526c › c-refcard.pdf pdf
C Reference Card (ANSI) Program Structure/Functions type fnc(type1,. . . )
C Reference Card (ANSI) Program Structure/Functions · type fnc(type1,. . . ) function declarations · type name · external variable declarations · main() { main routine · declarations · local variable declarations · statements · } type fnc(arg1,. . . ) { function definition ·
🌐
Columbia University
cs.columbia.edu › ~sedwards › papers › sgi1999c.pdf pdf
C Language Reference Manual 007–0701–130
We value your comments and will respond to them promptly. ... They use only those features of the language defined in the standard. ... They do not produce output dependent on any ill-defined behavior. Ill-defined behavior includes implementation-defined, undefined, and · unspecified behavior which refers ...