Function Parameter Pass by Value - C Function

C examples for Function:Function Parameter

Introduction

Variables are by default passed by value.

Only a copy of the value is passed to the function.

Changing the parameter in any way will not affect the original variable.

Since the value is copied during the passing, passing large variables back and forth can have a negative impact on performance.

Demo Code

#include <stdio.h>

void set(int i) { i = 1; }

int main(void) {
  int x = 0;/*from w ww  . j ava 2s  . c o  m*/
  set(x);
  printf("%d", x); /* "0" */
}

Related Tutorials