pointer increment

Conor P. Cahill cpcahil at virtech.UUCP
Sun Aug 13 01:39:08 AEST 1989


In article <484 at eagle.wesleyan.edu>, dkonerding at eagle.wesleyan.edu writes:
>         Now, say I make ptr=1000 or hex 3e8.  I want to add one to the ptr, to
> make it point to 1001, or hex 3e9.  Every time I do a ptr=ptr+1, it becomes
> 3ec.  How can I simply increment ptr by one?

By declaring the pointer as char * ptr;

an increment of a pointer moves the pointer to the next occurance of the
item to which it points to.  In your case I am assuming an integer is 4
bytes and the compiler correctly moved the pointer to point to the next
integer that ptr may point to.  This goes the same for structures.



More information about the Comp.lang.c mailing list