hi
i am not getting pointers concept.guide me to learn this concept.i can't understand the increment and decrement of pointer variable.
And maximum how many dereference operator you can apply in while declaring a pointer variable.

reply me asap

>i can't understand the increment and decrement of pointer variable.
Pointers are an abstraction. Think of it like this: a pointer points to a thing. When you increment a pointer, you tell it to point to the next thing. When you decrement a pointer, it points to the previous thing.

The way C makes this magic happen is by adding or subtracting N, where N is `number of things * size of one thing` . All of this is done behind the scenes, which is why p++ works correctly regardless of the size of the thing that p points to.

>And maximum how many dereference operator you
>can apply in while declaring a pointer variable.
Up to twelve, but if you get close to that, I'd question your sanity.

For pointer concept you look at the post by Naure I am just throwing some light on similarities between variable increment and pointer increment. (Thought that would help you link these two things and understand better.)

1)
variable + 1 = value of variable + 1
pointer + 1 = address pointed to by pointer + sizeof(pointer)

2)
variable++ = get value of variable , add one to it , store this value back into variable
pointer++ = get address pointed to by pointer , add sizeof(pointer) to it , make pointer point to this address

3)
variable + n (where n is any number )
value of variable + n

pointer + n (where n is any number )
address pointed to by pointer + n * sizeof(pointer)

4)
variable1 - variable2 = difference in their arithmetic value

pointer1 - pointer2 = difference in number of adresses
(they should be pointers to same type of variables as against the case in variable subtraction)

5)
Addition of pointers is not feasible but all addition of numeric constants to numbers can also be seen with subtraction of numeric numbers which act in reverse way.

6)
Multiplication division and all cannot be applied to pointers.

I hope this was of some help...

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.