Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

pass the pointer to the function

#include<stdio.h>

//pass the simple pointer to the function

void swapnum(int* i, int* j)
{
  	int tmp = *i;
  	*i = *j;
  	*j = temp;
}

int main()
{
  	int a = 10;
  	int b = 20;
  	swap(&a,&b);
  	printf("A is %d and B is %d
", a , b);
  	return 0;
}
Source by www.ibm.com #
 
PREVIOUS NEXT
Tagged: #pass #pointer #function
ADD COMMENT
Topic
Name
3+7 =