In article <HX8sg.141146$Mn5.44349@pd7tw3no>, a <a@mail.comwrote:
>Hi,
func(int* p){
p = p+1;
}
main(){
int* ptr;
//assume ptr is pointing to a valid allocated array
func(ptr);
//Will ptr equal the original address value
//or equal the original address + sizeof(int)??
}
Inside func, p is a *copy* of the value passed in. You then increment
that copy. The original is not changed.
If you did wish to permanently increment a pointer from inside a
function, you would have to pass the -address- of the pointer in,
and use that address to increment the value stored: that way what
the function receives is a copy of the address of the pointer, and that
copy of the address can be used to manipulate what is pointed to
(i.e., the pointer itself.)
--
Is there any thing whereof it may be said, See, this is new? It hath
been already of old time, which was before us. -- Ecclesiastes