hc19961106 2015-03-19 23:29 采纳率: 100%
浏览 1766
已采纳

c语言赋值的问题,看过来

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赋值

  • 写回答

1条回答 默认 最新

  • oyljerry 2015-03-20 01:58
    关注
     additem(5,3,&p1);
    

    传地址

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮