I have a question that may help me with my code. When we use reference the name of the array (without any indexing), what does this really mean?
I have a question that may help me with my code. When we use reference the name of the array (without any indexing), what does this really mean?
&array[0]
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
So basically does this means that it's calling the address of the array starting at subscript 0?
Would it take on the value of the whole array if it were to be passed into a function?
"Our greatest glory consists not in never failing,
but in rising every time we fall."
Oliver Goldsmith (1730-1774).
Anglo-Irish writer, poet and playwright.
An array argument is a pointer to the first element of the array, not the entire array.
Makes sense if you think about it. An array doesn't have a "value", per se, and even if it did, you sure wouldn't want to 'copy' an array of 100,000 bytes in order to pass it to a function 'by value'.
"Passing by reference"? Well, the problem is that a reference is a constant value which means that it can't be incremented/decremented the way pointers can. (Note the segue here. )
By passing a pointer to the array (first element), we've got the functionality that we're looking for without a ton of overhead.
-Skipper
"When the only tool you own is a hammer, every problem begins to resemble a nail." Abraham Maslow
Thanks Skipper.... actually made sense!! Appreciate it!