void additem(int coff,int exp,Node* pol)
{
struct node* p;
if(pol==NULL)
{
pol=(polynomial)malloc(sizeof(Node));
pol->next=NULL;
p=pol;
}
else
p=addnode(pol);
p->data.cofficient=coff;
p->data.exponent=exp;
}
Node* addnode(Node* pol)
{
Node* temp=pol;
while(temp)
temp=temp->next;
temp=(Node*)malloc(sizeof(Node));
temp->next=NULL;
return temp;
}
typedef struct{
int cofficient;
int exponent;
}Data;
typedef struct node{
Data data;
struct node* next;
}Node;
typedef Node* polynomial;
void initialize(Node*);
void additem(int,int,Node*);
Node* addnode(Node*);
#include
#include
#include "head.h"
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
polynomial p1;
initialize(p1);
additem(5,3,p1);
printf("%d",p1->data.cofficient);
return 0;
}
为什么始终不能给p1->data.cofficient赋值