C passes arguments by value, always, meaning that the called function receives a local copy of whatever the caller refers to.

The called function can modify the received value, because it is a local copy, without affecting the original value. For example:

char *test(char *s) {
  s++;
  return s;
}

t = test("A");

it's legal and shows that the parameter s can be modified without affecting the caller (which passes a literal...).

But the strcpy() of you example does something different: it takes a pointer s, and modifies what s points to. Pointers are powerful, and they can be used to simulate "pass by reference" (a pointer is a reference).

after assignment *s = *t is held, which one is compared with '\0'? *s or *t?

The *s: in C, an assignment returns a value - and the value is the value of the assigned variable after the assignment is done. Writing:

if (i=3) ...

is the same as

i=3;
if (i) ...

If i was a pointer the syntax would be different but the mechanism is the same, the assignment would "use" the pointer and the value of the whole assignment is used as expression to be evaluated in the test.

Answer from linuxfan says Reinstate Monica on Stack Overflow
🌐
ScholarHat
scholarhat.com › home › tutorials › call by value and call by..
Call by Value and Call by Reference in C
Call by value copies a variable's value whereas call by reference passes a pointer instead. Depending on what the output is supposed to be, developers need to decide which one they should use.
Published: August 2, 2025
🌐
GeeksforGeeks
geeksforgeeks.org › c language › difference-between-call-by-value-and-call-by-reference
Pass by Value Vs Pass by Reference in C - GeeksforGeeks
January 22, 2026 - In pass by value, the function receives a copy of the variable's value. Any changes made to the parameter inside the function do not affect the original variable in the caller. Two separate copies exist in memory: The original variable in the ...
Discussions

Why is everything in C call by value?
When you say that a language like Java is "pass-by-reference," it means that the language fundamentally handles objects via indirection. It's an actual language feature. Pass by reference is not a "feature" that exists in C, per se. It's an abstract concept that you can implement/realize in C by passing pointers to objects rather than passing the values themselves. It's a little confusing because in C, you implement pass-by-reference by passing pointers, by value. The "reference" part comes from the fact that the pointers allow you to "reach out" of the function's local scope and touch some external object, which is what we call "pass-by-reference." More on reddit.com
🌐 r/C_Programming
52
36
October 6, 2022
Is this call by reference or by value in C? - Stack Overflow
In latter point of view, it's definitely call-by-reference. Please tell me which way is correct and why, thanks! btw, after assignment *s = *t, which one is compared with '\0'? *s or *t? ... There is no concept in C to pass by reference like C++ has. ... In C++ you can pass by reference -- which indirectly is passing a pointer to the field you are passing ... All parameters are locals to the function, C only give parameter by copy, aka value... More on stackoverflow.com
🌐 stackoverflow.com
call by value and call by reference
In call by value, value being passed ... parameter, it is changed for the current function only. It will not change the value of variable inside the caller method such as main(). In call by reference, original value is modified because we pass reference (address).... More on youth4work.com
🌐 youth4work.com
49
April 11, 2023
Understanding "Call by Reference" and "Call by Value" in Programming Languages - Seeking Clarification for My Assigned Task
This is about how outer variables are treated in functions. I'll show the core concept in pseudocode. Passing an argument by value: fun change(v): #I use "fun" to denote it's pseudocode, not Python v = 10 a = 5 change(a) print(a) #outputs 5 - v was changed in function only Passing an argument by reference: fun change(ref v): #v is passed by reference v = 10 a = 5 change(a) print(a) #outputs 10 - function have changed its argument outside Passing an argument by reference allows a function to change the variable passed to it; passing an argument by value copies that value. If the value is big (like a string or array), it's faster to pass a reference than to copy it. Now, to Python. In Python, all variables are passed by reference. def change(l): l[1] = 1 a = [1,2,3] change(a) print(a) #[1,1,3] But wait! It doesn't work with numbers this way! def change(x): x = 1 a = 5 change(a) print(a) #still 5! Well yes, because in Python: - assignment operator changes the reference; - numbers are immutable, i.e. to change a number you need to create a new object and change the reference to it (that's one of the causes why Python is relatively slow). So, Python imitates "calling by value" with this. In Java, objects are passed by reference and primitive types are passed by value. More on reddit.com
🌐 r/learnpython
8
0
July 7, 2023
🌐
Scaler
scaler.com › home › topics › call by value and call by reference in c
Call by Value and Call by Reference in C With Program Examples
May 26, 2026 - In call by value, the function parameters gets the copy of actual parameters which means changes made in function parameters did not reflect in actual parameters. Here, the actual argument is passed to the function, but since the actual and formal parameters are stored in different memory ...
🌐
Reddit
reddit.com › r/c_programming › why is everything in c call by value?
r/C_Programming on Reddit: Why is everything in C call by value?
October 6, 2022 -

Edit3: THANK YOU SO MUCH, I UNDERSTAND IT BETTER NOW (I hope). Please don't delete any of the explanations because I wanna refer to them in the future when I get confused again. THANK YOU EVERYONE!!

I kind of understood call by reference vs call by value after reading this.

My understanding is int i stores the value and is called by value. int *j points to the memory address which stores the value, this is a call by reference.

I tried to understand CodeTinkerer's explanation but I still don't understand why doesn't it swap 3 and 5.

Doesn't it point to the address and should then swap the contents?

Edit: Referring to change(), not swap, I apologize for not mentioning this earlier.

Edit2: I'm reading everything, I just need time to digest it all. Thank you to those who have replied and I'm open to more explanations so thank you in advance too.

🌐
Tutorial Gateway
tutorialgateway.org › call-by-value-and-call-by-reference-in-c
Call By Value and Call By Reference in C
March 17, 2015 - Although we changed the a and b numbers in the CallByValue (), it will not reflect the originals because CallByValue () used a copy of the original values. We hope you understood the C Programming Language Call by Value, so let us explore the Call by Reference.
Top answer
1 of 2
5

C passes arguments by value, always, meaning that the called function receives a local copy of whatever the caller refers to.

The called function can modify the received value, because it is a local copy, without affecting the original value. For example:

char *test(char *s) {
  s++;
  return s;
}

t = test("A");

it's legal and shows that the parameter s can be modified without affecting the caller (which passes a literal...).

But the strcpy() of you example does something different: it takes a pointer s, and modifies what s points to. Pointers are powerful, and they can be used to simulate "pass by reference" (a pointer is a reference).

after assignment *s = *t is held, which one is compared with '\0'? *s or *t?

The *s: in C, an assignment returns a value - and the value is the value of the assigned variable after the assignment is done. Writing:

if (i=3) ...

is the same as

i=3;
if (i) ...

If i was a pointer the syntax would be different but the mechanism is the same, the assignment would "use" the pointer and the value of the whole assignment is used as expression to be evaluated in the test.

2 of 2
3

Many people consider that idiom to be something that’s neither call-by-value or call-by-reference. For what it’s worth, Kernighan and Ritchie’s The C Programming Language does call arrays and pointers in C “references,” although it uses only the term call-by-value and not call-by-reference. That usage seems to have gone out of fashion once C++ added a different language feature called references.

A function that accepts a pointer and dereferences it will generally compile to the same machine code as a function in a language with call-by-reference. One difference that is not merely the absence of syntactic sugar: if the pointer argument itself is not const, it is possible to reassign a new value to it and make it reference something else, which “call-by-reference” semantics do not allow. In a language with call-by-reference, you could not write s++ or t++ to make the function arguments reference different objects! (C strings are stored in such a way that you can add an offset to the pointer to obtain a substring, whereas most langauges store the length of the string in the first few bytes of its memory.) However, you can mostly think of a reference T& in C++ as equivalent to passing a T *const that is guaranteed not to be NULL, and that has an invisible asterisk in front of its name.

🌐
Educative
educative.io › answers › call-by-value-vs-call-by-reference-in-c
Call by value vs. call by reference in C
Call by value: A copy of the variable is passed to the function. Call by reference: An address of the variable is passed to the function.
Find elsewhere
🌐
Aticleworld
aticleworld.com › home › call by value and call by reference in c
Call by Value and Call by Reference in C - Aticleworld
July 13, 2020 - In the example code, swap() function ... of x and y remains the same. In the call by reference, addresses of the actual arguments are copied and then assigned to the corresponding formal arguments....
🌐
DataFlair
data-flair.training › blogs › call-by-value-and-call-by-reference-in-c
Difference Between Call by Value and Call by Reference in C - DataFlair
February 10, 2024 - Call by value and call by reference allow passing data to functions in different ways. Call by value maintains isolation while call by reference allows modifying actual arguments.
🌐
TutorialsPoint
tutorialspoint.com › cprogramming › c_function_call_by_reference.htm
Function Call by Reference in C
It can be termed as "mixed calling mechanism", where some of the arguments are passed by value and others by reference. A function in C can have more than one arguments, but can return only one value.
🌐
Log2Base2
log2base2.com › C › pointer › call-by-value-and-call-by-reference-in-c.html
Call by value and call by reference in c with example
/* * Program : Call by value example ... %d\n",a); set(a); printf("Main : After calling set function a = %d\n",a); return 0; } ... In call by reference, we pass the address of a variable....
🌐
Javatpoint
javatpoint.com › call-by-value-and-call-by-reference-in-c
Call by Value and Call by Reference in C - javatpoint
April 23, 2014 - Recursion in C Recursion is the process which comes into existence when a function calls a copy of itself to work on a smaller problem. Any function which calls itself is called recursive function, and such function calls are called recursive calls. Recursion involves several numbers of... ... We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
🌐
TutorialsPoint
tutorialspoint.com › cprogramming › c_function_call_by_value.htm
Function Call by Value in C
Refer the next chapter for a detailed explanation on the Call by Reference mechanism of C. The Call by Reference approach involves passing the address of the variable holding the value of the actual argument.
🌐
Rookienerd
rookienerd.com › tutorial › c › c-call-by-value-and-call-by-reference
Call by value and Call by reference in C - Rookie Nerd
Call by reference Example: Swapping the values of the two variables ... #include <stdio.h> void swap(int *, int *); //prototype of the function int main() { int a = 10; int b = 20; printf("Before swapping the values in main a = %d, b = %d\n",a,b); // printing the value of a and b in main swap(&a,&b); printf("After swapping values in main a = %d, b = %d\n",a,b); // The values of actual parameters do change in call by reference, a = 10, b = 20 } void swap (int *a, int *b) { int temp; temp = *a; *a=*b; *b=temp; printf("After swapping values in function a = %d, b = %d\n",*a,*b); // Formal parameters, a = 20, b = 10 }
🌐
Scribd
scribd.com › document › 340776619 › Call-by-Value-and-Call-by-Reference-in-C
Call by Value and Call by Reference in C
In call by value, the original value is not modified, while in call by reference it is modified. Call by value passes the value locally to the function, so changes inside the function do not affect the original variable.
🌐
Levelupsynergy
levelupsynergy.in › articles › call-by-value-call-by-reference-in-c
Call by Value & Call by Reference in C
Call by Value is used when we do not want the function to modify the original data. Call by Reference is used when we want the function to modify the original variable. In C, arrays are always passed by reference because their base address is ...
🌐
Medium
medium.com › @nikhilkumar.230816 › call-by-value-and-call-by-reference-in-c-d24c8fee0a0f
Call by Value and Call by Reference in C | by Nikhilkumar | Medium
September 24, 2020 - The significant distinction between call by worth and call by reference is that in the call by esteem a duplicate of genuine contentions is passed to particular proper contentions.
🌐
Codeforwin
codeforwin.org › home › function arguments in c – call by value and call by reference
Function arguments in C - Call by value and Call by reference - Codeforwin
July 20, 2025 - Therefore inside the swap() function values has been swapped, however original value of n1 and n2 in main() function remains unchanged. In Call by reference we pass memory location (reference) of actual parameter to formal parameter.