【C】结构体 struct
格式 struct 名称
struct Rectangle {
int width;
int height;
};
int area(struct Rectangle rectangle);
int area(struct Rectangle rectangle) {
return rectangle.width * rectangle.height;
}
int main(int argc, char *argv[]) {
struct Rectangle rectangle = {
.width = 10,
.height = 20
};
printf("the rectangle area is: %d", area(rectangle));
return 0;
}