Understand the priority rules declared in C Language

Source: Internet
Author: User

The priority rules of C language declaration mentioned in Expert C programming are as follows:

A declares that it reads data starting from its name and then reads data in order of priority;

The priority of B is from high to low:

B .1 The Section enclosed in parentheses in the statement;

B .2 suffix OPERATOR: brackets () indicate that this is a function, and square brackets [] indicate that this is an array;

B .3 prefix OPERATOR: asterisk * identifies "pointer ";

C. If the const and (or) Volatile keywords follow the type specifiers (such as int and long), it acts on the type specifiers. In other cases, const and (or) the volatile keyword acts on the pointer asterisk next to its left.

Examples:Char * const * (* Next )();

A next --- next is the declared name.

B .1 (* Next) --- next is a pointer...

B .2 (* Next) () --- next is a function pointer.

B .3 * (* Next) () --- next is a function pointer, which returns a pointer...

C char * const --- a constant pointer to a character type

Therefore, the meaning of char * const * (* Next) (); is:Next is a function pointer. This function returns a constant pointer to the character type.

Let's analyze a statement by ourselves:

INT (* Foo () [];

First, let's take a look at the result:Foo is a function that returns a pointer to an integer array.. Right? The following describes the specific derivation process:

A foo --- foo is the declared name.

B .2 Foo () --- foo is a function.

B .3 (* Foo () --- foo is a function that returns a pointer...

B .2 (* Foo () [] --- foo is a function that returns a pointer to an array.

C int (* Foo () [] --- foo is a function that returns a pointer to an integer array.

 

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.