# A couple questions

• 07-26-2005
fenixataris182
A couple questions
what arithmetic can you do with pointers? addition, subtraction, multiplication?

If you assign a 0 to a pointer would it make the pointer point to nothing?
• 07-26-2005
Prelude
>what arithmetic can you do with pointers?
You can add or subtract by an integer, or subtract by a pointer. All of these are only strictly defined for pointers into an array or simulated array.

>If you assign a 0 to a pointer would it make the pointer point to nothing?
Close enough, yes. :)
• 07-26-2005
fenixataris182
can a pointer variable store the address of another variable?

does an array's name store the address of the array's first element?

Is an array's name a pointer, constant, and a variable?
• 07-26-2005
XSquared
>can a pointer variable store the address of another variable?
Yes:
Code:

```int a; int *x=&a;```
x now points to the memory address of a.

>does an array's name store the address of the array's first element?
I always answer this wrong, so I'm not going to embarass myself.

>Is an array's name a pointer, constant, and a variable?
See above. :)
• 07-26-2005
Zach L.
The array's name is a pointer to the first (0th) element. The subscript simply adds that value to the base address (the first element of the array). For some fun, try the following (and you'll see what I mean):
Code:

```int array[4] = { 1, 2, 4, 8 }; std::cout << array[3] << std::endl; std::cout << 3[array] << std::endl;```
*edit*
I hope no one saw that. :cool:
• 07-26-2005
Prelude
>can a pointer variable store the address of another variable?
That's really the definition of a pointer, isn't it?

>does an array's name store the address of the array's first element?
No, but in most cases the name of an array is converted to a pointer to the first element.

>Is an array's name a pointer, constant, and a variable?
No, somewhat, and yes. Contradictory, no? ;) Try this on for size.