C language structure knowledge, basic knowledge points of C language structure.ppt

Basic knowledge of C language structure

Structure and Union 1 Structure Structure is a kind of construction data type purpose: to combine different types of data into a whole ------- custom data type structure type definition. 2 Definition of structure variables first Define the structure type, and then define the general form of the structure variable: When defining the structure type, define the general form of the structure variable: .3 Reference rules for structure variables Structure variables cannot be referenced as a whole, only variable members can be referenced 4 Structure Variable initialization form 1: 5 Structure array Structure array definition Three forms: Structure array initialization 6 Structure and pointer to structure variable pointer definition form: struct structure name * structure pointer name; for example struct student *p; Pointer to structure array Use pointer to structure as function parameter Use structure variable member as parameter----value pass use pointer to structure variable or array as parameter----address pass Structure variables as parameters ---- multi-value passing, inefficient C language notation of structure types Introduce three useful library functions (both in): sizeof(x) - calculate the length of variable x; malloc(m ) - open up an address space with a length of m bytes, and return the first address of this space; free(p) - release the storage space of the variable pointed to by the pointer p, that is, delete a variable completely. * struct [structure name] { type identifier member name; type identifier member name; …………. }; member type can be a basic type or a stereotype struct is a keyword, and legal identifiers cannot be omitted. Anonymous structure Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile 5.2.0.0. Copyright 2004-2011 Aspose Pty Ltd. Example struct student { int num; char name[20]; char sex; int age; float score ; char addr[30]; };

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324326402&siteId=291194637