This sample program in C demonstrates the concept of passing a pointer as a parameter to a function. In this program, the function "prompt" accepts two pointers. The second parameter (num) is a pointer to the variable i. Since it is a pointer, the function does not return the value. The value is stored in i itself.
#include <stdio.h>
void prompt(char *msg, int *num);
int main(void)
{
int i;
prompt("Enter a num: ", &i);
printf("Your number is: %d", i);
return 0;
}
void prompt(char *msg, int *num)
{
printf(msg);
scanf("%d", num);
}