Advertisements

Search results for function pointer

Example:[1]

            Write a c program function to swap two integers using function pointers.
          

            #include <stdio.h>
void (*fptr)(int * ,int * );
void function(int * ,int * );
int main()
{
	int num1 = 20,num2 = 30;
	printf("Before:%d,%d\n", num1,num2);
	fptr = function;
	(*fptr)(&num1,&num2);
	printf("After:%d,%d\n", num1,num2);
	return 0;
}
void function(int *a,int *b)
{
	int copy;
	copy = *a;
	*a = *b;
	*b = copy;
}
          

 Search Links


 Popular C search MCQs


 Popular C search examples