我对此代码有一些问题:
typedef struct Product {
char product_code[5];
int sells;
int sells_quantity;
}p[3];
typedef struct Seller {
char seller_code[5];
Product *ptr;
}seller[5];
为什么Product *ptr
给我一个错误?
答案 0 :(得分:1)
您可以尝试替换代码吗
typedef struct Product {
char product_code[5];
int sells;
int sells_quantity;
}p[3];
用
typedef struct Product {
char product_code[5];
int sells;
int sells_quantity;
} Product; // from here the structure type Product is recognized by the compiler.
答案 1 :(得分:0)
你可以这样做:
typedef struct Product {
char product_code[5];
int sells;
int sells_quantity;
}p[3],Product;
typedef struct Seller {
char seller_code[5];
Product *ptr;
}seller[5];