第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

c語言鏈表里面有一些概念不清楚,求大神給我講講

c語言鏈表里面有一些概念不清楚,求大神給我講講

C
依木蘭 2019-05-07 15:05:05
有點不明白鏈表里面的?struct node *head=(struct node*)malloc(sizeof(struct node));?struct node *ptail;?head=ptail;?這個是什么意思,讓ptail指向head節(jié)點嗎??struct node *head=(struct node*)malloc(sizeof(struct node));?struct node *ptail=(struct node*)malloc(sizeof(struct node));?head=ptail;?那么這個又是什么意思呢??還有 struct node *head=(struct node*)malloc(sizeof(struct node));?struct node *ptail;*pnew=(struct node*)malloc(sizeof(struct node));?head=ptail;?ptail->next=pnew相當(dāng)于head->next=pnew嗎?
查看完整描述

3 回答

?
qq_慕圣9438953

TA貢獻4條經(jīng)驗 獲得超0個贊

第一部分

?struct node *head=(struct node*)malloc(sizeof(struct node));?

這句話的意思是說:定義一個大小為struct node的內(nèi)存空間,這個內(nèi)存空間的首地址將儲存在struct node類型的指針變量head中

struct node *ptail;?

定義一個struct node類型的指針變量ptail

head=ptail;

將ptail賦值給head,也可以說是讓head指向ptail


第二部分

?struct node *head=(struct node*)malloc(sizeof(struct node));

?struct node *ptail=(struct node*)malloc(sizeof(struct node));?

這兩句話的意思是:分別分配兩塊struct node大小的內(nèi)存空間給指針變量head和ptail

head=ptail;

同理,讓head指向ptail


第三部分

?struct node *head=(struct node*)malloc(sizeof(struct node));

分配struct node大小的內(nèi)存空間給指針變量head

?struct node *ptail;

聲明指針變量ptail

*pnew=(struct node*)malloc(sizeof(struct node));

分配struct node大小的內(nèi)存空間給指針變量pnew?

head=ptail;?

讓head指向ptail

ptail->next=pnew

將指針pnew所指向的內(nèi)存空間的首地址,儲存在ptail的next元素中

這個操作相當(dāng)于head->next=pnew,但并不是隨時都如此,只有在head和ptail指向同一個內(nèi)存空間時才是這樣

查看完整回答
反對 回復(fù) 2019-05-22
  • 3 回答
  • 0 關(guān)注
  • 1027 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號