Is an array's name a pointer in C? If not, what is the difference between an array's name and a pointer variable?
相关问题
- Multiple sockets for clients to connect to
- Do the Java Integer and Double objects have unnece
- What is the best way to do a search in a large fil
- How to get the maximum of more than 2 numbers in V
- Faster loop: foreach vs some (performance of jsper
The array name by itself yields a memory location, so you can treat the array name like a pointer:
And other nifty stuff you can do to pointer (e.g. adding/substracting an offset), you can also do to an array:
Language-wise, if C didn't expose the array as just some sort of "pointer"(pedantically it's just a memory location. It cannot point to arbitrary location in memory, nor can be controlled by the programmer). We always need to code this:
The array name behaves like a pointer and points to the first element of the array. Example:
Both the print statements will give exactly same output for a machine. In my system it gave:
Array name is the address of 1st element of an array. So yes array name is a const pointer.