#include<stdio.h>
#include<stdlib.h>
typedef struct goods_node{
char number[10];
float price;
int sum;
struct goods_node *next;
} goods;
typedef struct customer_node{
char name[20];
char address[20];
char Tel[20];
struct customer_node *next;
} customer;
typedef struct order_node{
char orderNumber[10];
goods *a;
customer *c;
int amount;
float pay;
char status[20];
struct order_node *next;
} order;
void main()
{
order *c1;
goods *c2;
customer *c3;
c1=(order*)malloc(sizeof(order));
c2=(goods*)malloc(sizeof(goods));
c3=(customer*)malloc(sizeof(customer));
printf("please inlput:\n");
scanf("%s%f%s",c1->a->number,&c1->a->price,c1->c->Tel);
printf("%5s%6.1f%5s",c1->a->number,c1->a->price,c1->c->Tel);
}
想通过order这个结构体指向里面的goods和customer这两个结构体的变量,但是输不出来,请大神解答.....谢谢
在
c1=(order*)malloc(sizeof(order));下面添加
因为你虽然为c1,c2,c3分配了空间,但是没有为c1中的good *a和customer *c分配空间
谢谢你的回答,么么哒.....