Pointers seem to be the biggest thing everyone has problems with-- think of it this way--
Passing by Value= contents of variable
Passing by Reference = address of variable
Code:
void foo1(char); /* prototypes */
void foo2(char*);
int main(void);
int main(void)
{
char myLetter;
myLetter = 'X';
foo1(myLetter); /* pass by value (contents of 'myLetter') */
foo2(&myLetter); /* pass by reference (refer to contents by passing address of 'myLetter') */
return(0);
}
void foo1(char letter)
{
if(letter == 'X') /* look at value of 'letter' */
Beep();
}
void foo2(char *letter)
{
if(*letter == 'X') /* go through 'letter' which is address of original variable to get to contents */
Beep();
}
enjoy.