Pointers and Arrays • An array's name is a constant whose value is the address of the array's first element. For this reason, the value of an array's name cannot be changed by an assignment statement or by any other means. • A pointer is a variable whose address value can be changed by assignment.
Using Array Name float on_time_rate[100]; float *ptr; ptr = on_time_rate; Or equivalently ptr = &on_time_rate[0]; • Once ptr is assigned value, you can use ptr as an array, e. g. , ptr[0], ptr[1], …, ptr[99] This is the same as *ptr, *(ptr+1), …, *(ptr+99)
Pointer to char and Array of char *s = "My Brother"; • Declares a pointer s to char, initializes it to the starting address of a string. char c[]= "My Car"; • Declares an array c of size 7, with c[0]='M', c[1]='y', …, c[5]='r', c[6] ='