Categories
c c++ dereference pointers

What’s the difference between * and & in C?

I’m learning C and I’m still not sure if I understood the difference between & and * yet.

Allow me to try to explain it:

int a; // Declares a variable
int *b; // Declares a pointer
int &c; // Not possible
a = 10;
b = &a; // b gets the address of a
*b = 20; // a now has the value 20

I got these, but then it becomes confusing.

void funct(int a) // A declaration of a function, a is declared
void funct(int *a) // a is declared as a pointer
void funct(int &a) // a now receives only pointers (address)
funct(a) // Creates a copy of a
funct(*a) // Uses a pointer, can create a pointer of a pointer in some cases
funct(&a) // Sends an address of a pointer

So, both funct(*a) and funct(&a) are correct, right? What’s the difference?