is actual argument an array or singular pointer?

Quiz: pretend to be a typical c/c++ function at run time. If one of the arguments to the function is declared an int* pointer, how do you know if real thing is an array or a single pointer?

A: if this is the only argument, then you can’t tell. There has to be another argument like “int size”
A: however, if the argument is char*, then there may not be a size argument. Assume C-string please.

As a function parameter, a simple pointer is indistinguishable from an array.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s