瀏覽單個文章
superintel
Power Member
 

加入日期: May 2002
文章: 560
Cool

你是在龍門補資節的嗎??
(我覺得老師都把簡單的東西複雜化,像這個東西沒必要用到雙指標ㄟ)
你用dev c++自己把code執行一遍,就會了解了!!
而 temp=(struct stackekement *)malloc(size(struct stackekement));
這行可換成
temp=new stackekement; (c++語法,簡單,明瞭多了)



引用:
作者53346
老師說以下這個程式你真的能夠了解,那指標的部分你就沒問題了,想忘也會忘不掉...
struct stackekement{
int element;
struct stackelement *next;
}
struct stackekement*stack;

stack=NULL;

void push(int stackin,struct stackelment **stack)
{struct stackekement *temp;

temp=(struct stackekement *)malloc(size(struct stackekement));
temp->element=stackin;
temp->next=*stack;
*stack=temp;
}
...POP的部分略刪,上課了時候老師有在黑板上畫圖解釋這個程式,看的時候還勉強可以
理解,但是下課後自己看到後面就傻掉了...
想請問:
1.一開頭的"struct stackekement{"是什麼意思??宣告第一個大括弧裡面的東西而已?
那這樣第一個大括弧下的"struct stackekement*st...
舊 2005-07-21, 11:12 PM #7
回應時引用此文章
superintel離線中