Constructed type: array \ enum \ struct #import <Foundation/Foundation.h>
struct: Constructed type, is a custom type.
struct cpoint//struct is a keyword used to declare that a struct is followed by the name of a struct. The contents of the curly braces are called member variables
//{
float x;
Float y;
};//with a semicolon-terminated typedef struct car{
Char name[20];
int number;
Float score;
}ca;
struct//anonymous struct No name struct declaration and struct variable are put together, not commonly used
//{
Char name[20];
Char happy[20];
}L1 = {"Yuanxinfeng", "NV"};
typedef The first typedef is a good way to simplify struct names, so it is recommended to use TypeDef for the second type
typedef struct Student Stu;
//
typedef the second Kind
typedef struct PERSON{CHAR name[20];
char gender;
int number;
float score;//}per;////Structure body occupancy rule: 11 memory-occupying member variable type is Unit 2 top-down classification
struct student{
Char name[10];
int score;
int age;
float x;
Char y;
Double z;};/ /40//Access member variables use the. struct variable name for access. Member variable name//printf ("%s%c%d%.2f\n", s1.name,s1.gender,s1.number,s1.score);printf ("%s\n", S1.name);//printf ("%s%c%d%.2f\n", s1.name,s1.gender,s1.number,s1.score);
S1.score = 98;
S1.gender = ' m ';
S1.number = 10;
strcpy (S1.name, "Yuanxinfeng");//string array can not be assigned directly, use function to assign value
S1 = s2;//struct variable can be directly assigned//printf ("%s%c%d%.2f\n", s1.name,s1.gender,s1.number,s1.score);//struct nested//Multiple data---using arrays
Constructed type: array \ enum \ struct