iTaChi 19 Newbie Poster

>Not necessarily. There's no guarantee that the address of the array as a whole is the same as the address of the first element. That's usually the case though.

Its right, but you wouldnt call the array itself because they have different values, so the first value of the array is the same with the array itself if and only if the array only contains 1 value which is the first value..

iTaChi 19 Newbie Poster

I just was wondering why the array its self are a pointer to the first element?
and what is the difference between an array and a pointer?

nice question!

first, i want you to read a definition of arrays,

An array is an example of a homogeneous random access data structure. An array is merely a collection of similar data elements such as integers, floats, characters, etc. which is stored together with a common name, and addressed by means of index that tells the location of the particular data entity in the array..

When we use homogeneous to an array, it means that each cells have the same data type, and the random-access aspect tells that we can access any of the cells of an array directly by just using its indices.

for example, given is an array a[50], (note that an array begins in 0) in a[20] we assigned a value of 10 and in a[2] we assigned a value of 30. we can make use of this values simply by using the array's indices, for example,

a[20] + a[2] is similar to 10 + 30..


now, we can relate pointers to arrays..we can say that any cell of an array can be a pointer. an array can hold data value and its address..


good luck!

~s.o.s~ commented: Good one. +19
iTaChi 19 Newbie Poster

in declaring and defining functions, you should know that there should be no whitespaces in the name,

also, you should assign the correct data type to a variable you declared, if you want it to function as a character, you should assign it as a char type.

good luck!