Is an array name a pointer?

An array is an array and a pointer is a pointer, but in most cases array names are converted to pointers. A term often used is that they decay to pointers. Here is an array: int a[7]; a contains space for seven integers, and you can put a value in one of them with an … Read more

Crash or “segmentation fault” when data is copied/scanned/read to an uninitialized pointer

A pointer is a special type of variable, which can only contain an address of another variable. It cannot contain any data. You cannot “copy/store data into a pointer” – that doesn’t make any sense. You can only set a pointer to point at data allocated elsewhere. This means that in order for a pointer … Read more

What is array to pointer decay?

It’s said that arrays “decay” into pointers. A C++ array declared as int numbers [5] cannot be re-pointed, i.e. you can’t say numbers = 0x5a5aff23. More importantly the term decay signifies loss of type and dimension; numbers decay into int* by losing the dimension information (count 5) and the type is not int [5] any … Read more