1、Programming In C Contents 01 02 how to use members in structure variables Memory alignment The dot here is called member operator. How to use members in structure variables The form of referencing a member in a structure variable is: structure variable names. member names How to use members in struc
2、ture variables A structure variable to be directly assigned to another structure variable, with the same structure. s2= s1; The assignment of the structure uses the method the memory copy the individual member copy int a10; Int b10; a=b; struct example int a3; array1,array2; Array1=0,1,2; array2=arr
3、ay1; struct memnumber int a; double b; char c; number1; /take up 4 bytes /take up 8 bytes /take up 1 bytes sizeof( number1) !=13 sizeof( number1) =24 memory alignment Memory alignment There is a requirement for the storage location of variables in memory in many systems. That is the addresses storin
4、g the structure objects and their members are multiples of a certain number. This is the structure memory alignment principle. In order to meet this principle, compiler fill in bytes between members . Memory alignment 成员 a 成员 b 成员c take up 4 bytes fill in 4 bytes take up 8 bytes take up 1 bytes fill in 7 bytes Example struct memnumber int a; char c; double b; number1; Programming In C