"Bill Potter" <lo********@com cast.net> wrote in message
news:yv******** ************@co mcast.com...
I am a learning programmer in C and i want to know why some one would use
pointers instead of going direct!
for many reasons! 2 simple ones:
1) when passing a large structure to a function, we dont want to copy every
element and slow things down to a snail-pace. So pass a pointer instead,
which is very quick.
2) what if you want some information to be passed to a function and that
function modifies some data. For example a sort function. We pass a
pointer to an array to the function and let it do all the work.
Basically, pointers speed things up. They also allow dynamic memory
allocation using malloc() or equivalent. Things start to get more advanced
when you have pointers to pointers ;-)
Allan