typedef insight is how to define an array pointer

Source: Internet
Author: User

What I want to say today is my opinion about TypeDef, not the opinion, but the understanding!

typedef: Take a name for the custom data type; I understand that;

For example, an array of int a[5] and an int B, also define a data variable, can we let int a[5] write as simple as int b? So there's a typedef. You can name the custom data type, and this usage will be used in the renaming of struct struct;

typedef int AA[5];//Defines the data type of an array here, remembering that only memory is allocated, that there is no space allocated, and that the types and variables are not the same

typedef int (*AA1) [5];//defines an array pointer type here, at the same time

{

int//The only way to write this is to not allocate memory space

int a_1;//This is the ability to successfully define a variable, that is, to allocate space for it

aa//(IBID.) AA is just a data type, which cannot allocate memory space by a data type; So you also define a variable name

AA a_2;//Here is a successful definition of an array of a_2, in fact, can be seen in this way AA a_2==> int a_2[5]; just less write [5], feel some like a macro replacement;

So if we want to define an array pointer: You can write this

int (*a_3) [5];//This is one of our usual

Or with our custom data type;

AA *a_4;//This is the same as a normal array pointer usage, because a one-dimensional array a_4 equivalent to a first-level pointer, then *a_4 is equivalent to a level two pointer

or the Third kind.

Aa1 a_5;//to customize an array pointer variable

A_4 = &a_2;//a_2 is equivalent to a first-level pointer, and the address can be passed to a level two pointer.

}

These are typedef.

  

typedef insight is how to define an array pointer

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.