45 lines
1.0 KiB
C
45 lines
1.0 KiB
C
|
#include <stdio.h>
|
||
|
#include <string.h>
|
||
|
|
||
|
struct user_s
|
||
|
{
|
||
|
int uid;
|
||
|
char *name;
|
||
|
};
|
||
|
|
||
|
struct goods_s
|
||
|
{
|
||
|
int gid;
|
||
|
float price;
|
||
|
char *name;
|
||
|
};
|
||
|
|
||
|
struct order_s
|
||
|
{
|
||
|
struct user_s user;
|
||
|
struct goods_s goods;
|
||
|
float order_price; // 订单总价
|
||
|
int num; // 购买数量
|
||
|
int pay_status; // 支付状态 0:未支付 1:已支付 2:取消支付
|
||
|
};
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
struct user_s user1 = {1, "disen"};
|
||
|
struct user_s user2 = {2, "lucy"};
|
||
|
struct goods_s goods1 = {201, 1200.0f, "华为手表"};
|
||
|
struct goods_s goods2 = {202, 225000.0f, "华为汽车"};
|
||
|
struct order_s order1 = {
|
||
|
user1,
|
||
|
goods1, 1200.0f, 1, 1};
|
||
|
struct order_s order2 = order1;
|
||
|
// order2.user.name = "小李子";
|
||
|
// order2.goods.name = "华为汽车";
|
||
|
|
||
|
order2.user = user2;
|
||
|
order2.goods = goods2;
|
||
|
|
||
|
printf("order1 %s 购买 %s 订单状态: %d\n", order1.user.name, order1.goods.name, order1.pay_status);
|
||
|
printf("order2 %s 购买 %s 订单状态: %d\n", order2.user.name, order2.goods.name, order2.pay_status);
|
||
|
}
|