- 论坛徽章:
- 0
|
- #include<string.h>
- #include<stdio.h>
- #include<stdlib.h>
- //typedef struct {
- // char *productName;
- // char *productCata;
- // int productNum;
- // int productPreis;
- //
- //} Data;
- typedef struct {
- char *productName;
- char *productCata;
- int *productNum;
- int *productPreis;
- struct Node *left;
- struct Node *right;
- } Node;
- void list_add(Node *root, char *name, char *cata, int num, int preis){
- struct Node *node = (Node*)malloc(sizeof(Node));
- node->productName = (char *) malloc(strlen(name) + 1);
- node->productCata = (char *) malloc(strlen(cata) + 1);
- node->productNum = (int *)malloc(sizeof(num));
- node->productPreis=(int *)malloc(sizeof(preis));
- }
复制代码
binaryT.c: In function 'list_add':
binaryT.c:26: warning: initialization from incompatible pointer type
binaryT.c:27: error: dereferencing pointer to incomplete type
binaryT.c:28: error: dereferencing pointer to incomplete type
binaryT.c:29: error: dereferencing pointer to incomplete type
binaryT.c:30: error: dereferencing pointer to incomplete type
刚接触C 不久,感觉C的指针比面向对象的思想还难 |
|