问题描述
- c语言赋值的问题,看过来
- void additem(int coffint expNode* 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(intintNode*);
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(53p1);
printf(""%d""p1->data.cofficient);
return 0;
}
为什么始终不能给p1->data.cofficient赋值
解决方案
additem(53&p1);
传地址
时间: 2024-09-08 10:45:34