C Language Construction type:
A constructed type is made up of several members, each of which is a basic data type.
Construction data types can be nested, and constructs are constructed inside. The structure can be passed as a function parameter, which facilitates the writing.
to define a struct body:
1 Struts struct name { 2 member list 3 };
statement:
1 Struts student{2 int num; 3 Char name; 4 Char sex; 5 int score; 6 };
Defined:
1 Struts student Stu;
Array of structures, each element of the array is a struct of the same type
1 //initialization method of structure array2 3 //1. When defining an array of structures, initialize4 5 structstudent{6 7 Charname[ -];8 intAge ;9}boys[3] = {{"SS", -},{"KJH", -},{"WHJS", +}};
ways to access its members:
struct variable name. Member Name
C-language pointers:Declares a pointer that holds the address declaration of variable A:
1 int *nam = &a
2//*nam = a am = The address of variable a
Self-Understanding: "*" is the pointer's flag, "*" + pointer variable name = the value of the variable being pointed to. "&" is the address symbol. "&" + variable name = Address of change amount.
enum Type: keyword: enumAn enumeration type is a basic data type, not a constructed type, because it can no longer be decomposed into any base type. All possible values are listed in the definition of the enumeration type. Structure of the enumeration type:
1 enum Enum type name {enumeration value table}
typedef keyword:You can take the alias ~ format for the data type:
1 typedef primitive type name new type name
To alias an array:
1 //alias to array ~2typedefintarray[5];//int A[5] array length is 53ARRAY A1 = {1,2,3,4,5};4ARRAY B1 = {5,4,3,2,1};5 6 for(inti =0; I <5; i++){7printf"%d\t", B1[i]);8 }9 Ten return 0;
Operating Result: 5 4 3 2 1
macros in the C language: keywords: #defineThe identifier that is defined as "macro" is called "Macro name", and in compiling preprocessing, all occurrences of the "macro name" in the program are substituted with the string in the macro definition, which is called "macro substitution" or "macro expansion". The macro name that appears in the string is not replaced. Macros can be defined in a nested set. Like what:
1 #define R 42#define PI 3.143#define
You can use the #undef to cancel the # define custom macro name in uppercase letters to make it easier to differentiate from variables. However, lowercase is also allowed. Definition form:
1 #define Identifier string
A macro with parameters, in the call, not only to expand, but also to use the actual parameter to replace the parameter. Form:
#define Macro name (formal parameter list) string
1 /*Macro #define SUM (a) A+a2 SUM (3) not only a+a the substitution, but also takes the argument 3 into the string3 4 */5#include <stdio.h>6 #defineSUM (a) a+a7 8 intMainintargcConst Char*argv[]) {9 Ten intresult = SUM (3); Oneprintf"%d\n", result); A return 0; -}
Operation Result: 6
the difference between typedef and # define:You should be aware of the difference between using a macro definition to represent data types and defining data specifiers with TPYEDEF. Macro definition knowledge simple character substitution, is done in preprocessing, and TypeDef is processed at compile time, he is not a simple substitution, but the type specifier renamed. The named identifier has the function of the description of the type definition.
I am a dark horse-----Iosc language Advanced First part