Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report