Hi.
1) You've got it. No matter how it is termed or what goes on behind the scenes, ultimately "int &a" is just a fancy-pants way of saying "int *a" (but with all kinds of useful protections built-in).
2) Pointers are not arrays. Check out the "Articles" page of this website. There are a good number of postings there all about arrays and pointers.
The thing to remember is that the name of the array, all by itself, is roughly equivalent to a pointer, in that it yields the address of the first element of the array. So the following are exactly equivalent:
1 2 3
|
int a[ 42 ];
a[ 7 ] = 0; // same as...
*(a + 7) = 0; // ...this
|
The variable "a", however, is const. You cannot change the address of the beginning of the array by assigning to it.
3) No. Arrays must have length.
That said, you _can_ typecast to an array of unknown length. Remember, the array already exists --it has length-- only the compiler doesn't know what it is. You will occasionally see things like
1 2 3 4 5 6
|
struct tag_string {
unsigned length;
unsigned capacity;
unsigned reference_count;
char data[];
};
|
Likewise you will see functions with parameter lists like
void my_foo( int a[], unsigned length );
If this is beyond you right now, don't worry about it. You'll learn in time. (Alas I'm too tired to explain more than this ATM. Sorry.)
4) What kind of program would you like to see?
Hope this helps.