|
藍森林 http://www.lslnet.com 2006年6月6日 10:18
在線等待:能不能這樣定義結構體
struct link {
int num;
struct link *next;
} start,*node,new_num,*point; |
在線等待:能不能這樣定義結構體
沒有問題。只是這樣看起來不清晰。
用typedef就好了。 |
在線等待:能不能這樣定義結構體
絕對正確。有灌水嫌疑^_^。 |
在線等待:能不能這樣定義結構體
node->;next = (struct link *) malloc(sizeof(struct link));
new_num = (struct link_new *) malloc(sizeof(struct link_new));
那為什麼上面的定義出錯了???:) |
在線等待:能不能這樣定義結構體
struct link_new是什麼呀?沒定義啊。另外第二個應該是
new_num = (struct link_new )malloc(sizeof(struct link_new));
吧。 |
在線等待:能不能這樣定義結構體
-->
看不懂你要做什麼?
你的new_num是什麼類型?
而struct link_new *又是什麼類型?匹配嗎? |
在線等待:能不能這樣定義結構體
不好意思,我自己有點亂了,sorry!!! |
在線等待:能不能這樣定義結構體
/*定義要插入的數據*/
struct fist {
int num;
struct fist *next;
}inst,*point;
inst->;then = (struct fist *) malloc(sizeof(struct fist));
錯誤是:Point Require on left side of ->; in function main |
在線等待:能不能這樣定義結構體
大哥,->;左邊應該是變量還是指針?
不會不知道吧。 |
在線等待:能不能這樣定義結構體
能不能這樣:
struct fist {
int num;
struct fist *next;
}inst,*point;
int *temp;
point=&
temp=point->;next; |
在線等待:能不能這樣定義結構體
你的temp什麼類型?
而point->;next又是什麼類型呢?
你怎麼連類型都分不清楚呢? |
在線等待:能不能這樣定義結構體
兩個都是指針類型啊,只不過一個是指向結構體的指針啊,不可以這樣嗎? |
在線等待:能不能這樣定義結構體
-->
inst.then = (struct fist *) malloc(sizeof(struct fist)); |
在線等待:能不能這樣定義結構體
-->
那應該怎麼將他們相互賦值呢? |
在線等待:能不能這樣定義結構體
-->
先弄清楚你自己這裡的幾個東西到底是什麼意思
new_num,start是一個類型為struct link的變量
point,node是一個指針,應該指向一個struct link結構變量
指針和變量的調用方式,賦值方式都是比較基本的,還是翻翻書再說的好 |
在線等待:能不能這樣定義結構體
基本上都是結構名字和結構體中的變量定義錯誤 |
在線等待:能不能這樣定義結構體
呵呵...
不是所以人都可以掌握指針的.它是需要天賦地.
--------某c語言大牛說的 |
在線等待:能不能這樣定義結構體
-->
只要努力,誰都可以掌握的,
只是程度不一樣而已。 |
在線等待:能不能這樣定義結構體
讀書去吧! |
| |