Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

C Passing Pointers to Functions

#include <stdio.h>

void addOne(int* ptr) {
  (*ptr)++; // adding 1 to *ptr
}

int main()
{
  int* p, i = 10;
  p = &i;
  addOne(p);

  printf("%d", *p); // 11
  return 0;
}
 
PREVIOUS NEXT
Tagged: #C #Passing #Pointers #Functions
ADD COMMENT
Topic
Name
9+7 =