正在加载图片...
创建一个新节点 struct student"CreateNodeo struct student*p: p=( struct link)mdlc( sizeof( struct link):/^动态申请一段 内存 i印(==NULL)/申请失败,打印错误信息,退出程序* printf"No enough memory to alloc") exit(o) /*结束整个程序的运行* /*为新建节点赋值* p->next=NULL:⌒新建的节点指针域赋空指针*/ printf"please input number:");/*为新建的节点数据区赋值*/ gets(p->num): printf( please input score: ) scanfC %od", &p->score) printf("\n successful create a new node! ): eturn P 1010 创建一个新节点 struct student *CreateNode() { struct student *p; p = (struct Link *)malloc(sizeof(struct Link)); /* 动态申请一段 内存 */ if(p == NULL) /* 申请失败,打印错误信息,退出程序 */ { printf("No enough memory to alloc"); exit(0); /*结束整个程序的运行*/ } /*为新建节点赋值*/ p->next = NULL;/* 新建的节点指针域赋空指针 */ printf(“please input number:”); /* 为新建的节点数据区赋值 */ gets(p->num); printf(“please input score:”); scanf(“%d”,&p->score); printf("\n successful create a new node!"); return p; }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有