Explain what technology is, why and how it is used
A structure is a data type
Why do we need structures?
In order to represent some complex things, ordinary basic types cannot meet the actual requirements
What is a structure?
Combining some basic data types together forms a new composite data type, which is called a structure
How to define a structure?
#include <stdio.h>
//第一种定义结构体
struct Student
{
int age;
float score;
char sex;
}
//第二种方式定义结构体
struct Student2
{
int age;
float score;
char sex;
} st2;
//第三种方式
strct
{
int age;
float score;
char sex;
} st3;
int main()
{
}
How to take out each member in the structure variable:
1. Structure variable name. Member name
2. Pointer variable name -> member name (this is more commonly used)
pst->age will be converted into (*pst).age inside the computer
expand:
Neither float nor double can be stored accurately