【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;
}

 

posted @ 2023-08-03 22:55  翠微  阅读(6)  评论(0编辑  收藏  举报