Skip to content

Instantly share code, notes, and snippets.

@Warwolt
Created April 10, 2019 12:58
Show Gist options
  • Save Warwolt/0eb5f195952f4ce85aaf65ca22ff9055 to your computer and use it in GitHub Desktop.
Save Warwolt/0eb5f195952f4ce85aaf65ca22ff9055 to your computer and use it in GitHub Desktop.
void add_num(int num)
{
num += 1;
}
void add_num_ptr(int* num)
{
*num += 1;
}
int main(void)
{
int number = 12;
printf("%d\n", add_num); // prints 12
printf("%d\n", add_num); // prints 12
printf("%d\n", add_num_ptr(&num)); // prints 13
printf("%d\n", add_num_ptr(&num)); // prints 14
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment