No matter how tempted, do not read anything about pointers that invites you to think of them as house numbers written on paper, or pigeons, or telephone exchanges, or any other distracting, broken analogy :)

Edited 3 Years Ago by Moschops

Here its not possible to exaplain all aspect of pointer , so in very short you can understand the pointer as:-

A special type of variable (Different from oridinary variable)
Basically used to store address of other variable (i.e Pointer variable's value is address of another variable)
Pointer variable has power to access that referenced variable
we can create a variable as pointer type by simply adding the sign *

for ex:-

int i;
int *j; //pointer type variable
j=&i;   //assigning address to the pointer variable j

hope this helps a little bit to understand the basics of pointers

A special type of variable (Different from oridinary variable)

What's special about it? A variable holds a value. A pointer's value is an address. How is that different enough to warrant being called "special"? Further, what constitutes an "ordinary" variable? Be forewarned, if you say int is an ordinary variable then I'll respond by saying that both int and pointers are scalar variables that are nearly identical in concept and functionality. ;)

Really the only thing that could be construed as "special" about pointers is support for the indirection operator (this also happens to be the most confusing part of pointers). But that's just different, not special. int supports the multiplication and division operators while pointers do not. Does that make int special? ;D

Basically used to store address of other variable

To be strictly correct you'd say a pointer just stores an address. Or if you want to be especially pedantic, the C standard says that a pointer is an object whose value provides a reference to an entity of the referenced type. Consider this:

char *p = malloc(N);

The only variable involved is the pointer, so how can you say that it points to another variable?

@deceptikon(Agree with your post)
thanks for pointing out and disclosing the real fact.
Actually my above post was the result of what i saw in some local books (when i started learning c as the base for other languages) and now after searching something more on the topic Pointer , i really feel that i didnt grasp all things regarding Pointer.

so once again thanks for pointing out. . .

dear sir, can you help me to write a program to print the following out put:
abcd 1234
bcd1234
cd1234
d1234
1234
234
34
4

Edited 3 Years Ago by muhayimana: before they was a mistake

Firstly,i am Rwadaise so i am very happy to chare with you. I great you .and i want to know many of you like:schol-R-LEA,Deception .

int main()
{
    int i = 0;
    while (i!=010) printf("%s\n", &(i++["abcd1234"]));
}

Edited 3 Years Ago by Moschops

This article has been dead for over six months. Start a new discussion instead.