Skip to content

Instantly share code, notes, and snippets.

@EteimZ
Created November 27, 2023 12:16
Show Gist options
  • Select an option

  • Save EteimZ/9501b78ca343746eb15c45d205e2738f to your computer and use it in GitHub Desktop.

Select an option

Save EteimZ/9501b78ca343746eb15c45d205e2738f to your computer and use it in GitHub Desktop.
Demonstraing passing by reference in C.
#include <stdio.h>
void incr(int *x){
*x += 1;
}
int main(){
// initialize i to be equal to 6
int i = 6;
printf("i = %d\n", i);
// increment it by passing it's value by reference
incr(&i);
printf("i = %d\n", i);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment