Hey guys,
Im reading up on pointers and since i dont have a physical teacher, Its abit hard concept to grasp. Could anyone please explain in their own words shortly how they work, I understand that they carry the adress of another variable, and you'd assign this adress with an '&' sign, but I just cant understand once you have the *p=&b, does it mean that now you work with *p just like with b? and why down the road i see p without asterix sign before it., im confused, anyone could clearify in easiest possible way?
Any help would be greatly appreciated!!!
Rhanx a lot!

Cheers


andre

int i;
int *p;

p = &i;   // p holds the address of i

*p = 10;

The last assignment says take the value in p, go to that address and put 10 there.
Therefore, i now holds 10.

To prove that you could print either of these because they are identical.

printf("i is %d", i);      // prints 10
printf("i is %d", *p);  // prints 10
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.