#include #include struct goods_s { char name[30]; float price; }; int main() { struct goods_s g1 = {"华为手机", 6500}; struct goods_s g2 = g1; // 两个相同结构的变量可以直接赋值(浅拷贝: 复制第一层内存空间) strcpy(g2.name, "华为平板"); g2.price = 9000.0f; printf("商品名称:%s 价格:%.2f\n", g1.name, g1.price); printf("商品名称:%s 价格:%.2f\n", g2.name, g2.price); return 0; }