Google

Friday, January 22, 2010

CSC202 & ENG4033M : Function call by reference

//Function Call-By-Reference
#include "stdio.h"
//Function Prototype (Declaration)
void doubleIt(int* n);

int main()
{
//Function Call
int b = 2;
doubleIt(&b);
printf("result = %d\n",b);
return 0;
}

void doubleIt(int* n) //pointer
{
*n = (*n)*2;
}