Get the App
SLTechnology News&Howtos  ›  Development  › 

Example analysis of first-level pointer, second-level pointer, pointer array, array and pointer in C #

Shulou Source: shulou.com Published: 2022-06-02 02:18:00 09月30日 Update

Xiaobian to share with you in c# first-level pointers, secondary pointers, pointer array, array and pointer example analysis, I hope you will learn something after reading this article, let's discuss it together!

Pointers and arrays

The pointer is a variable used to store the address

& arr represents the entire array

The arr array name represents the address of the first element

Pointer dereferencing indicates what the pointer points to.

For example: char ptr= "abcdef"

The dereference of the ptr; / / pointer indicates what it points to, that is, abcdef

The address of the string is stored in ptr; / / ptr

two。 First-order pointer

The first-level pointer refers to the pointer, in which is the address of the element, we can access the address of the element to find the content stored in that address, that is, the element itself.

For example: char str1 [] = {1, 2, 3, 4, 5, 5, 7}

3. Secondary pointer

The second-level pointer is the pointer to the first-level pointer, which stores the memory address of the first-level pointer variable.

For example: int axi10

Int pa=&a

Int * ppa=&pa;// means that the address of an is stored in pa, the address of pa is stored in ppa, pa is the first / / level pointer, and ppa is the second-level pointer.

4. Pointer array

First of all, the pointer array is an array, each element of the array is a pointer type, where the pointer is used to modify the array, on a 32-bit platform, the pointer accounts for 4 bytes.

For example: char arr [4] = {"hello", "world"}; / / the arr here is an array of pointers with two elements, each of which is a pointer type.

So how do you tell whether an array is an array of pointers?

The best way is to add (), for example: char (arr [4]); secondly, we can also use symbols and []

To determine its association.

After reading this article, I believe you have a certain understanding of "sample analysis of first-level pointers, second-level pointers, pointer arrays, arrays and pointers". If you want to know more about it, you are welcome to follow the industry information channel. thank you for reading!

Tags: Pointers arrays addresses elements that is content points examples caches analysis variables articles types two priority memory can pass size characters strings Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Huawei Xiaomi MySQL Shulou Tech Info