Tuesday 5 March 2013

CALL BY REFERENCE

#include<stdio.h>
#include<conio.h>
void ref(int *p, int *q);
main()
{
int a = 5;
int b = 8;
printf("Before calling the function, a = %d and b = %d\n", a, b);
ref(&a, &b);
printf("After calling the function, a = %d and b = %d\n", a, b);
getch();
}
void ref(int *p, int *q)
{
(*p)++;
(*q)++;
printf("Inside function *p = %d, *q = %d\n", *p, *q);
}

No comments:

Post a Comment