Jump to: navigation, search

Pass by value is a term describing function call semantics. To pass by value means that the argument (a variable, constant or other expression) is evaluated and a copy of its value is then passed to the function.

Whenever the function accesses the parameter it receives, it does so without reference to the original argument which cannot be overwritten; nor can a volatile argument change the value of the parameter once the function is entered. Pass by value semantics can be contrasted with pass by reference semantics, which C does not directly support.

Quick examples

The program below

#include <stdio.h>
void foo(int x);

int main(void) {
  int i = 5;
  printf("In main(): %d\n", i);
  printf("In main(): %d\n", i);

  return 0;

void foo(int x) {
  printf("In foo(): %d\n", x);
  x = 10;
  printf("In foo(): %d\n", x);


 In main(): 5
 In foo(): 5
 In foo(): 10
 In main(): 5

See also


  • ISO C Standard, Function Calls
Personal tools