請教C語言內的指標傳遞

看板Programming作者時間18年前 (2006/10/28 17:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
請教一下,我的指標變數之間互相傳遞資料 為何以下的方式不行,而得用 sub(p,p);呢? 我想把*p丟給*x 不能直接丟嗎? 謝謝 附上原始碼如下 #include <dos.h> #include <stdlib.h> main() { void sub(int *,int*); int *p,a=1; p=&a; sub(*p,*p); printf("%d\n",*p); system("PAUSE"); return 0; } void sub(int *x,int *y) { *x=2; printf("%d %d\n",*x,*y); *y=3; printf("%d %d\n",*x,*y); } -- ┌─────KKCITY─────┐  動態歌詞 讓你成為K歌之王! bbs.kkcity.com.tw \^_^ / http://www.kkbox.com.tw └──From:59.125.181.196 ──┘   唱片公司授權,音樂盡情下載 --
文章代碼(AID): #15GnnF00 (Programming)
文章代碼(AID): #15GnnF00 (Programming)