Pointers to arrays

Source: Internet
Author: User

First of all, think about it? Is it possible to iterate through an array with a for?

Can actually be but, not the real sense of traversal,

for loop traversal, only suitable for index array, because we are to get the array subscript, and then use the subscript to access the elements of the array, but, logically, the subscript is part of the array, must be the first element to get the element subscript!

We are accustomed to using foreach to iterate through an array, because the reason for the foreach nature is that the pointer to the array can be found directly!

In the array of pointers, there is probably a common function: Key current next reset

Key syntax is: Key ( array name )

Function: Gets the key of the current element of the array!

Current syntax is: current ( array name )

Function: Gets the value of the current element of the array!

Next syntax is: Next ( array name )

Function: Moves the pointer of an array down one

Reset syntax is: RESET ( array name )

Function: Resets the pointer to an array (the pointer to the array is re-directed to the first element)

Code Case:

Pointers to arrays

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.