B
Bill Potter
I am a learning programmer in C and i want to know why some one would use
pointers instead of going direct!
pointers instead of going direct!
Bill Potter said:I am a learning programmer in C and i want to know why some one would use
pointers instead of going direct!
Bill said:I am a learning programmer in C and i want to know why some one would use
pointers instead of going direct!
Bill Potter said:I am a learning programmer in C and i want to know why some one would use
pointers instead of going direct!
Bill said:I am a learning programmer in C and i want to know why some one would use
pointers instead of going direct!
In C - as distinct from C++ - using a pointer is the *only* way a called
function can alter the contents of a variable in the calling function.
Parameters are passed in C in what is called "pass by value", that is, a
*copy* is passed to the callee.
Goran Larsson said:The same reason why we use pointers in human languages, e.g.
"home" instead of "17859 Main Street"
"the car behind us" instead of "car with registration no KN5567YZ"
"you" instead of "Bill Potter"
Bill said:I am a learning programmer in C and i want to know why some one would use
pointers instead of going direct!
Stephen Sprunk said:Actually "17859 Main St" is a pointer as well; the house itself is not.
Obviously every time you invite someone over, you'd rather give them a
pointer to your house instead of building a copy and handing it to them.
Bill Potter said:I am a learning programmer in C and i want to know why some one would use
pointers instead of going direct!
Bill said:I am a learning programmer in C and i want to know why some one would use
pointers instead of going direct!
Goran said:No. "17859 Main St" is the name of the house (variable).
Default User said:No, it's not, it's the address of the house. If you tore it down and
built an office building called "the doctor's cooperative", it would
still be at 17859 Main St.
Bill Potter said:I am a learning programmer in C and i want to know why
some one would use pointers instead of going direct!
Bill said:I am a learning programmer in C and i want to know why some one would use
pointers instead of going direct!
I am a learning programmer in C and i want to know why some one would use
pointers instead of going direct!
So you're saying the address of the house is the address of the house...?
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.
Emmanuel Delahaye said:A pointer is avariable.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.