
因為如果是L的話,就要把整個這個結構體都傳過去,效率不高,而用其指針傳遞的只是一個地址,效率要高很多,尤其對于大型程序來說。而且creat函數(shù)里有*L,這就是指向結構體了,剛好需要傳指向結構體 的指針,所以只能取址L,說白了 一個穿的是指針,而一個傳的是結構體,效率高下之分一看就知道

創(chuàng)新互聯(lián)提供成都網(wǎng)站制作、成都網(wǎng)站設計、網(wǎng)頁設計,成都品牌網(wǎng)站建設,1元廣告等致力于企業(yè)網(wǎng)站建設與公司網(wǎng)站制作,10多年的網(wǎng)站開發(fā)和建站經(jīng)驗,助力企業(yè)信息化建設,成功案例突破上千家,是您實現(xiàn)網(wǎng)站建設的好選擇.
你說的如果是自定義函數(shù)。就先寫出來,比如
#include
void create()
{
//這里寫函數(shù)代碼
}
int main()
{
create();//在主函數(shù)里進行調(diào)用
}
#include stdio.h
#include malloc.h
#include string.h
#define N 5
typedef struct node
{
char number[10];
int data;
struct node *next;
}node;
node * create()
{
node *p,*s,*h; char number[10];
int j=1,x;
p=s=h=(node*)malloc(sizeof(node));
h-next=NULL;
printf("please input the data to create the list,end with -1 or %d numbers\n",N);
while(x!=-1j=N)
{
printf("input name:");
scanf("%s",number);
printf("input age:");
scanf("%d",x);
s=(node*)malloc(sizeof(node));
s-data=x;
strcpy(s-number,number);
if(h-next==NULL)
h-next=s;
else
p-next=s;
p=s;
j++;
}
p-next=NULL;
return h;
}
int main()
{
node *p;
p=create() ;
return 0;
}