Function Parameter Pass by Address - C Function

C examples for Function:Function Parameter

Introduction

We can use pointer syntax to pass the variable by address.

An argument passed by address can be changed and the change will affect the original variable.

Demo Code

#include <stdio.h>
void set(int* i) { *i = 1; }

int main(void) {
  int x = 0;/* w w w  .  ja  v  a 2  s . c  o  m*/
  set(&x);
  printf("%d", x); /* "1" */
}

Related Tutorials