C language omission sorting and omission sorting

Source: Internet
Author: User

C language omission sorting and omission sorting

2017-06-10

The pointer flexibility in C language correctly recognizes the combination of the Array Function const and pointer.

 

(1) sort out the following special features of other types of pointers:

Interpretation Method: int a; type specifier variable name;

But the difference between pointers is that there are two ways to interpret the pointer. We can say that the pointer is the wall grass, and the sides are down. The specific usage is as follows;

Int *;

Interpretation Method 1: type specifier variable name; here it means that int * is type character a is variable.

However, this method may lead to misunderstanding. To apply for multi-variable int a, B, c; but the user will write the form as int * a, B, c According to this idea; so this is wrong, therefore, you need to note that the disconnection method is int * a; just disconnect * from the variable. However, the meaning is still the type specifier variable name. At this time, the user's application habit is int * a, * B, * c;

Interpretation Method 2 1 pointer Unit 2 pointer symbol 3 variable; int *;

2 A pointer 3a points to 1 pointer unit int;

Explanation Method: three trees

For more information, see int a. Let's take the variable array function struct in this example as the type specifier variable name. (all types except variables are type specifiers ). Two ways to interpret the pointer at the same time;

The preceding two methods are used to explain the relationship between the following special case pointer array functions;

A. int * a [3]; array char * test (a, B); Function

B. int (* a) [3]; pointer char (* test) (a, B); pointer

Pointer is the wall grass

If it is not emphasized, the group in the upper case from left to right is int * char *, which is the same data type as int,

In group B, when there is a wall (parentheses) pointer to this side of the variable, it is a pointer a pointing to the type int [3]; pointing to the type char (a, B );

 

For assignment, the object of pointer a's assignment is a pointer of the int [3] type, for example, int B [3] a = & B;

The function name is similar to the array name, which has the address feature. Therefore, you can use the test = function name without an address character;

However, the virtual address of the user needs to be added during the assignment process: test = (&) function name; this & here is a hypothetical, which makes it easier to understand the subsequent function execution, it is easy to understand and does not really mean it. (Abandon bad ideas)

The function execution method is test (); or (* test) (); that is, the function can be executed without adding a star number. By default, the function is called without a star number, however, in order to partition the time-sharing pointer, the star number and Asterisk removal are also correct.

Not to mention the pointer, no matter when (normally we call the sub-function without adding a star number, but it is good if you add it, but you didn't try it ).

(2) const's interpretation of modifier variables is also the variable name split into type specifiers;

For example, int const;

Const int;

Const int * a; // pointer interpretation method 2. pointer a points to const to modify int-type data, that is, the object pointed to by the pointer is modified by const, and the data cannot be modified by the pointer; object

Int * const a; // interpret a pointer a. a is modified by const and points to int type. pointer

 

Name Definition

Function pointer

Const

 

Related Article

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.