一个小问题,路过大侠帮忙
我们数据结构的老师不教单链表,说是用指针太麻烦,用数组也能够实现,没办法只好上来求教.
代码如下,看严蔚敏的书里面差不多是这样写的,可编译不了,主要是那个"init_ysf(ysf*&h)"理解不了...
#include<stdio.h>#include<malloc.h>#define LEN sizeof(ysf)struct ysf{ int num; int len; struct ysf *next;};typedef struct ysf ysf,*hysf;void init_ysf(hysf&h){ h=(hysf*)malloc(LEN); h->len=1; h->next=NULL;}int main(){ hysf head; init_ysf(head); printf("%d",head->len);}