Wednesday, June 27, 2007

what are Pointers in "C"

Here lets go about learning and arguing about pointers and arrays in the C Programming language

Pointer is nothing but a type that points to a particular data type
Suppose i say int *p;
Here p is a pointer to a int datatype and int alone
So p will store the address of the memory location of a integer variable and any integer variable(as of now our p stores nothing).
Diagramatically p will have an arrow pointing to an integer variable.Simle rite.yes things are cool till now

Lets go on with some assignments :
int *p;(we now know what happens here)
int i = 25;(we know what happens here as well - if not this is not the place for you......oh!!i meant u better learn the basics and come)


p = &i; // this rtaher creates an arrow from i and puts it with p...programatically & gets the address of that variable.so now p has the address of the integer variable i.

Thus things should be fine now..thats it with the basics of what is pointer.see the other osts for more advanced stories on pointers

Thanks,
Prasanna

No comments: