想要将商品信息读入链表中,但编译发生错误,求解;
代码如下:
```c
```#include<stdio.h>
```c
```#include<stdlib.h>
```c
```#define GOODS_FILE_NAME "goodsinfo.txt"
```c
```#define MAX_ID_LEN 30
```c
```#define MAX_NAME_LEN 30
```c
```#define MAX_PRICE_LEN 30
```c
```#define MAX_DISCOUNT_LEN 30
```c
```extern int CurrentCnt;
```c
```typedef struct {
```c
``` char goods_id[MAX_ID_LEN];
```c
``` char goods_name[MAX_NAME_LEN];
int goods_price;
char goods_discount[MAX_DISCOUNT_LEN];
int goods_amount;
int goods_remain;
} GoodsInfo;
```c
```typedef struct node
{
GoodsInfo data;
struct node *next;
} GoodsList;
int main ()
```c
```{
```c
```GoodsList **L;
```c
```GoodsInfo info;
GoodsList head_list=(GoodsList)malloc(sizeof(GoodsList)),*p;
*L=head_list;
FILE *fp=fopen("goodsinfo.txt","r");
if(fp==NULL){
printf("error: file not found");
```c
```return 0;
```c
``` }
```c
```else {
```c
```while(!feof(fp)) {
```c
```fscanf(fp,"%s%s%d%s%d%d",info.goods_id,info.goods_name,&(info.goods_price),info.goods_discount,&(info.goods_amount),&(info.goods_remain));
```c
```p=(GoodsList *)malloc(sizeof(GoodsList));
```c
```head_list->next=p;
```c
```head_list->data=info;
```c
``` CurrentCnt++;
```c
```}
}
fclose(fp);
p->next=NULL;
printf("商品的链表文件已建立,有%d个商品记录\n", CurrentCnt);
}
编译错误如下: